develooper Front page | perl.perl5.porters | Postings from November 1999

Re: Regex match variables, threads, and recursion

Thread Previous | Thread Next
M.J.T. Guy
November 6, 1999 09:00
Re: Regex match variables, threads, and recursion
Message ID: wrote
> Interesting.  I've never expected $1 et alia to be lexical and I've
> always treated them as equivalent to "volatile" as in C.  Their values
> can change at any time, if you need to keep them around for any
> reason, store them somewhere.

I've never expected them to be lexical, if only because they're
explicitly defined to be localised.    So code like the following
"does the right thing":

             sub doit { print "$1\n" };
             'abc' =~ /(b)/;

Not that I've ever had any desire to write any such code.   Having $1
and co as lexicals would undoubtedly be "better", but the compatibility
issues would have to be addressed.

Mike Guy

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About