Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Re: largest number inside array/hash

by Anonymous Monk
on Apr 07, 2004 at 04:39 UTC ( [id://343188]=note: print w/replies, xml ) Need Help??


in reply to Re: largest number inside array/hash
in thread largest number inside array/hash

This does not contain any data, it doesn't store anything in $max and I know the hash works because I'm using it elsewhere.
my $max; grep($max=($_>$max)?$_:$max,keys %files); print $max;

Replies are listed 'Best First'.
Re: Re: Re: largest number inside array/hash
by matija (Priest) on Apr 07, 2004 at 05:39 UTC
    I really, really doubt that.

    Here is the code I tested with, and it's 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";
    Output:
    perl /tmp/foo 6 8 1 34 7 9 2 5 <34>
    I don't know what you did to mess up, but it does so contain data, and stores the max.

    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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://343188]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-25 04:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found