develooper Front page | perl.perl5.porters | Postings from September 2013

Re: [perl #120047] perl should enable "$_" for use before callingsubs

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
September 30, 2013 01:06
Subject:
Re: [perl #120047] perl should enable "$_" for use before callingsubs
Message ID:
20130930010606.GA16970@fernweh.plasmasturm.org
* Linda Walsh via RT <perlbug-followup@perl.org> [2013-09-30 02:20]:
> if I have:
>
> sub reader() {
>   my save=$_";
>   open(my $fh, "<myfile") or die "open:$!";
>   while (<$fh>) {
>   ...
>   }
>   $_=$save;
> }

Yes if you have that, you change the `my $save = $_` to `local $_`
and you drop the last line. Case closed.

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