On Thu, 25 Aug 2011 10:08:55 -0700
mer...@stonehenge.com (Randal L. Schwartz) wrote:

> >>>>> "Shlomi" == Shlomi Fish <shlo...@shlomifish.org> writes:
> 
> Shlomi> I also tend to avoid using "$_" (except for map/grep/etc. where
> Shlomi> it is required), because it can be clobbered and devastated too
> Shlomi> easily, which also makes depending on it error prone.
> 
> Well, that's interesting.  I've *never* accidentally clobbered
> $_. Nearly everything that uses $_ localizes it immediately, except for
> the implicit assignment to $_ during a while-reading-filehandle loop, or
> being the target of a s/old/new/ operation, which I consider something
> to learn properly in the first few hours of Perl because it happens so
> often.
> 
> Can you give an example from your old code where you "accidentally"
> clobbered $_?
>

Well, I believe I've always avoided using an implicit $_ as preventative
measure (out of thinking I know better) and so cannot present such a case
first-hand. However, see:

http://www.forum2.org/gaal/perl/Pitfall/slide001.html - “A $_ Gotcha”.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
"The Human Hacking Field Guide" - http://shlom.in/hhfg

The cool thing about Vim is — you find something interesting with every typo.
    — Su‐Shee on Freenode’s #perl .

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to