| Next | Tricks of the Wizards | 94 |
The rest of it is mostly an exercise in regexology
sub translate_code {
my $doing_a_string = shift;
my $result = "";
while (1) {
if ($doing_a_string) { # Handle backslashes
/\G((?:\\\\)+)(?!=\\)/gc and $result .= $1, next;
/\G((?:\\\\)+)\\./sgc and $result .= $1, next;
}
if (/\G([\$\@\%]) ($name) ($P) /sgcx) {
my $arrow = "";
my ($sigil, $var, $subs) = ($1, $2, $3);
$arrow = "->" if $sigil eq '$';
$result .= join "", '$', $var, $arrow, $subs;
next;
}
/\G([\w\s]+)/gc and $result .= $1, next;
/\G(.)/sgc and $result .= $1, next;
last;
}
$_ = $result;
}
The real Perl6::Variables is just a more extensive exercise in regexology
| Next | ![]() |
Copyright © 2003 M. J. Dominus |