in reply to Re: Re: largest number inside array/hash
in thread largest number inside array/hash
Here is the code I tested with, and it's output:
Output:#!/usr/bin/perl my %files=%{{1=>"a", 2=>"b", 34=>"c", 5=>"d", 6=>"e", 7=>"f", 8=>"g", +9=>"h"}}; my $max; print join(" ",keys %files),"\n"; grep($max=($_>$max)?$_:$max,keys %files); print "<$max>\n";
I don't know what you did to mess up, but it does so contain data, and stores the max.perl /tmp/foo 6 8 1 34 7 9 2 5 <34>
My guess is that if you try it with your files, you'll find it either works, or your hash doesn't look the way you expect. (Hint: try to output it with Data::Dumper
|
---|