Next | Tricks of the Wizards | 93 |
package Perl6::Variables; use Regexp::Common; use Filter::Simple;
FILTER_ONLY code => \&translate, string => \&translate_string, ;
Filter::Simple will call translate_string on each string in the program
It'll also call translate on the entire code, but with the strings 'blanked out'
That way we needn't worry about applying code transformations to strings
Filtering strings is similar to filtering code
Except we have to worry about backslash escapes
Perl 6 Perl 5 --------------------------- @array[3] $array[3] \@array[3] \$array[3]" "@array[3]" "$array[3]" "\@array[3]" "\@array[3]"
So translate_string will pass a flag to translate to tell it to handle backslashes
sub translate_string { translate_code(1) }
Next | Copyright © 2003 M. J. Dominus |