develooper Front page | perl.beginners | Postings from February 2012

Re: stopping global substituion under MACOSX

Thread Previous
From:
Uri Guttman
Date:
February 22, 2012 08:39
Subject:
Re: stopping global substituion under MACOSX
Message ID:
4F451A0E.1070601@stemsystems.com
On 02/22/2012 03:02 AM, timothy adigun wrote:

> So, if John suggestion doesn't work as it should, then you may have to
> enable slurp mode like this:
>      $/=undef or local $/;
>    So your code could read:
>
>    {
>       .....
>       $/=undef;   ## or use local $/;

those are not equivilent. the first is setting $/ to undef and it will 
last past the block, affecting all other <> calls. the local one will 
set it only for the duration of this block but also for any calls made 
inside this block that also may do <> ops. in general neither is a good 
idea. use File::Slurp if you want to read whole files in. it is cleaner 
and also faster than setting $/ to undef.

>       $text=~s/george/tim/;
>        ........
>    }

uri

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