Simply put because while doesn't work like that :)
Explicitly, while doesn't iterate over the items of a list in the way that for does and it doesn't set $_ unless the expression is the diamond operator.
To get your example to work with while you will need to do something like :
my @foo = sort (keys %data); while( $_ = shift @foo ) { print "while: $data{$_}\n"; }
/J\
In reply to Re: While on hashes doesn't work?
by gellyfish
in thread While on hashes doesn't work?
by blahblah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |