in reply to Re: finding next key in db_file
in thread finding next key in db_file
my $current = 5; my %hash = ( "1" => "one", "2" => "two", "3" => "three", "4" => "four", "5" => "five", "8" => "eight" ); while ($current) { $current++; if (exists $hash{$current}) { print "next: $hash{$current}"; last; } }
Update: solution for finding the highest num
my $highest = 0; foreach my $key (keys %hash) { if ($key > $highest) { $highest = $key; } } print "\nhighest number is: $highest";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: finding next key in db_file
by bobf (Monsignor) on Aug 16, 2006 at 04:55 UTC | |
by sulfericacid (Deacon) on Aug 16, 2006 at 05:04 UTC |