Gisle Aas <[EMAIL PROTECTED]> writes:
> > $turl->authority($1);
>
> This does not actually work with current URI module. Use
>
> $turl->authority("$1");
>
> as a workaround.
The reason for this bug is the following perl behaviour:
--------------------------------------------
sub foo
{
my $foo = shift;
print "Arg 1 is $foo\n";
$foo =~ /(\w)/ || die;
print "Arg 2 is ", shift(), "\n";
}
foo("a", "b");
"ab" =~ /(b)/ || die;
print "\$1 is $1\n";
foo("a", $1);
foo("a", "$1");
--------------------------------------------
This prints:
Arg 1 is a
Arg 2 is b
$1 is b
Arg 1 is a
Arg 2 is a
Arg 1 is a
Arg 2 is b
I would argue that perl ought to be smarter an actually do the right
thing. What currently happens is that $1 is automagically localized
inside the function as it should be, but this localization also kills
the $1 alias we have in $_[1]. $_[1] ought to stay an alias for the
outer $1.
URI.pm could workaround this problem by always making a copy of @_
before it use any RE, but that seems unattractively expensive and
ugly.
Regards,
Gisle