I'm working on a library of rules and subroutines for dealing with UNIX
system files. This is really just a mental exercise to help me grasp the
new pattern stuff from A5.
I've hit a snag, though, on hypothetical variables. How would this code
work?
{
my $x = 2;
my $y = "The grass is green";
$y =~ /(gr\w+) {let $x = $1}/;
}
I assume that it would change C<$x> from C<2> to C<"grass">. But here's
the case where I'm concerned:
module foo;
rule gr_word { (gr\w+) {let $x = $1} }
----my code----
use foo;
my $x = 2;
"The grass is green" =~ /<gr_word>/;
Would my local C<$x> be reset to C<"grass">? That would seem to lead to
some very ugly namespace problems, since the module user never asked to
have C<$x> replaced, it's just a silent side-effect.
Please tell me there's some magic way that this works, so that I'm wrong
:)