Not recommending it, but perhaps it gives insight into
how while works (in addition to what gellyfish said above)
#!/usr/bin/perl -w
use strict;
my %data = ( a01 => "two",
a02 => "peas",
a03 => "in",
a04 => "a",
a05 => "pod."
);
while (($_) = sort keys %data){
print "while: $data{$_}\n";
delete $data{$_};
}
print "while loop terminates because",
"%data is now empty >", %data,"< \n";
__END__
Without those parens around $_, I would expect it to try to pass '5' into the block (which it would do if you took away the
sort function), but it doesn't do that. I suppose that might qualify as an insignificant bug.
update: thanks to
merlyn for fixing the bug in my understanding of how
sort behaves.
mkmcconn
</code>