in reply to Iterating over verbatim hash reference

for( my $h = { qw' x 5 y 8 ' }; my($r,$s)=each %$h; ){ print " $r = $s \n"; } __END__ y = 8 x = 5
You're the first person to call it verbatim hash in 10 years :) SPRINGLE

Replies are listed 'Best First'.
Re^2: Iterating over verbatim hash reference
by rovf (Priest) on Jan 21, 2010 at 14:20 UTC
    This doesn't answer my question, because you are introducing a variable for the hash ref here, i.e. $h. Of course this works, as you see from the 2nd example in my original posting. The point is to do it without naming the hash/hashref.

    -- 
    Ronald Fischer <ynnor@mm.st>
      ... without introducing a new variable ...

      The following variation doesn't introduce a new variable because  $_ already exists! (I believe the following is also Stupid Hash Trick #58.)

      >perl -wMstrict -le "for ({ qw(a 1 b 2 c 3) }) { while (my ($k, $v) = each %$_) { print qq{$k => $v}; } } " c => 3 a => 1 b => 2
      It isn't possible, you need a name.