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

Re: Regex match variables, threads, and recursion

Thread Previous | Thread Next
From:
M.J.T. Guy
Date:
November 6, 1999 09:00
Subject:
Re: Regex match variables, threads, and recursion
Message ID:
E11k9Cr-0003CU-00@taurus.cus.cam.ac.uk
duff@cbi.tamucc.edu 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)/;
             doit();

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


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