Jim Gibson wrote:
NO it is not. The way to diagnosis this type of problem is to look at the
contents of your variables, either by stepping through your program with a
debugger or by adding print statements to your program. If you do that, you
will find that the @next array is not assigned the key/value pairs of the
hash in the loop. Hint: you are missing a call to each.



Trying to understand bit better I play the working script a bit..

When I do this.. I thought I would get all the pairs in %files but I only got five 5 pair.. which is the last one.
I am definitely not understanding this well.. trying more.

use warnings;
use strict;
use Data::Dumper;

my %files = ( one => 1, thirty => 30, four => 4, never => 997,
   forever => 100001, five => 5 );
my @max = each(%files);
=pod
while ( @max ) {
   print "$_ yahoo \n";
}
=cut
print Dumper(@max);

while( my @next = each(%files) ) {
   @max = @next if $next[1] > $max[1];
}
print "biggest: (@max)\n";



././././test2.pl
$VAR1 = 'five';
$VAR2 = 5;
biggest: (forever 100001)

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to