This behavior looks like Perl might be using a "pass by
implicit reference, break reference and create local copy
if modified" strategy.
This can improve performance, but can be really confusing
when one passes a global variable to a function that
modifies the original global.
Gisle Aas wrote:
> The URI module have problems because of the following behaviour
> of $1 in subroutine argument lists (@_):
> -----------------------------------------------------
> #!/usr/bin/perl -w
>
> "foobar" =~ /(o+)/;
>
> foo($1); # prints "a"
> foo("$1"); # print "oo"
>
> sub foo
> {
> "foobar" =~ /(a+)/;
> print "@_\n";
> }
> __END__
> ------------------------------------------------------
>
> I get the same result with perl5.004, perl5.005 and perl5.6.0.
> I assume this is a perl bug. Is it easily fixable?