in reply to Dereference a hash constant
Try it this way:
use constant foo => { a .. z };; [0] Perl> print "$k : $v" while ($k,$v) = each %{ foo() };; w : x e : f a : b m : n s : t y : z u : v c : d k : l q : r g : h i : j o : p
Or this:
[0] Perl> print "$k : $v" while ($k,$v) = each %{ +foo };; w : x e : f a : b m : n s : t y : z u : v c : d k : l q : r g : h i : j o : p
The 'trick' is to ensure that foo is parsed as a sub not a string or bareword.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dereference a hash constant
by wrinkles (Pilgrim) on Oct 22, 2009 at 06:45 UTC | |
|
Re^2: Dereference a hash constant
by Anonymous Monk on Oct 22, 2009 at 00:45 UTC |