Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: problem with array of hashes

by daxim (Chaplain)
on Oct 09, 2012 at 10:34 UTC ( #997972=note: print w/ replies, xml ) Need Help??


in reply to problem with array of hashes

The expression +(sort { $a <=> $b } keys %{ $VAR1->[0] })[0] returns 41.


Comment on Re: problem with array of hashes
Download Code
Re^2: problem with array of hashes
by tobyink (Abbot) on Oct 09, 2012 at 10:47 UTC

    So does:

    my ($value) = map { join('array of hashes', 41) } $VAR;

    Update: added parentheses. Thanks McA.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

      Oh, oh, oh

      Guys, look at this:

      use strict; use warnings; use Test::More tests => 2; my $the_ultimate_answer = 42; my $VAR1 = [ { '201' => 'i', '101' => 'f', '41' => 't', } ]; is(+(sort { $a <=> $b } keys %{ $VAR1->[0] })[0], $the_ultimate_answer +, 'Testing for ultimate answer'); my $value = map { join('array of hashes', 41) } $VAR1; is($value, $the_ultimate_answer, 'Testing for ultimate answer');

      The second proposal is more wrong than I expected. ;-)

Re^2: problem with array of hashes
by grizzley (Chaplain) on Oct 09, 2012 at 11:13 UTC
    ...and print +(sort {$VAR1{$a} <=> $VAR1{$b}} keys %{$VAR1->[0]})[-1]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2014-10-25 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (141 votes), past polls