develooper Front page | perl.perl5.porters | Postings from April 2000

Re: URI::path() confused by $1

Thread Previous
From:
Ron Wilson
Date:
April 7, 2000 13:24
Subject:
Re: URI::path() confused by $1
Message ID:
38EE440F.DDD17073@connectex.com
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?

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About