in reply to Re: non aliased default var $_
in thread non aliased default var $_

Thanx, my $_ = $_; is really a good idiom!

In this example with map it might look complicated, because we have to define a return value...

...but in a for loop it's easy to spot, understand and handy to use.

Perfect! :)

Cheers Rolf

Replies are listed 'Best First'.
Re^3: non aliased default var $_
by Anonymous Monk on Mar 10, 2010 at 14:26 UTC
    is really a good idiom!

    For modern perl (5.10+)

      from perlsub

      The fix is to add local():

      local $_ = 5;

      ...

      As of perl 5.9.1, you can now use a lexical version of $_ by declaring it in a file or in a block with "my".

      Cheers Rolf