LanX has asked for the wisdom of the Perl Monks concerning the following question:

UPDATE
The trouble with playing around inside the debugger is, that you sometimes forget about changes you made days ago in the same session.

Like playing around with aliases like *b = *a

Hence the rest of this post is obsolete ...

My bad, sorry! =)

Original
When playing around with while / each idiom, I thought using the globals $a,$b for key/value could be a cool idiom.

(They are global because of sort )

well ... it fails... WHY? looks like a strange aliasing effect...

DB<111> say "$a,$b" while ($a,$b) = each %$h 3,3 10,10 34,34 7,7 DB<112> say "$k,$v" while ($k,$v) = each %$h Z,3 a,10 b,34 A,7 DB<113> my ($a,$b); say "$a,$b" while ($a,$b) = each %$ Z,3 a,10 b,34 A,7 DB<114> while( ($a,$b) = each %$h ) { say "$a,$b" } 3,3 10,10 34,34 7,7 DB<115> while( my ($a,$b) = each %$h ) { say "$a,$b" } Z,3 a,10 b,34 A,7 DB<116> dd $h { a => 10, A => 7, b => 34, Z => 3 } DB<117> ... DB<120> dd [($a,$b) = each %$h ] [3, 3] DB<121> p $] 5.024001 DB<122>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery