in reply to uninitialized $_ sneaks past warnings in grep/map block or expression

Are you sure it's not documented in perlvar? The entry for $_ states when it is used as an iterator or the destination of an input record for a while loop. If it's not defined, it's not defined. If it is being given a value by a for loop, a while loop with a readline operator, given, grep, or map, then it is defined.
  • Comment on Re: uninitialized $_ sneaks past warnings in grep/map block or expression

Replies are listed 'Best First'.
Re^2: uninitialized $_ sneaks past warnings in grep/map block or expression
by JavaFan (Canon) on Sep 01, 2010 at 16:00 UTC
    If it is being given a value by a for loop, a while loop with a readline operator, given, grep, or map, then it is defined.
    Not if the value given isn't defined.
    $ perl -wE 'say for 1, undef, 3' 1 Use of uninitialized value in say at -e line 1. 3

      That's a trick. You've very specifically given it a non-value. ;-)