in reply to Sorting values of nested hash refs
Addon: If you use List::Util you can make it a little bit easier:#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $hoh = { '3094507' => { '2838413' => '22', '2976790' => '33', '539960' => '10', '2152725' => '19', '161546' => '5', '2197572' => '3' }, '2946464' => { '2952428' => '9', '3913125' => '10', '790014' => '2', '1065575' => '3' }, '2565888' => { '10538' => '1', '744' => '2' }, }; my @results; foreach my $outer (keys %$hoh) { foreach my $inner ($hoh->{$outer}) { my $max = 0; for (values %$inner) { $max = $_ if ($_ > $max); } push @results, $max; } } print Dumper(@results);
best regards, neniromy $max = max (values %$inner);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Sorting values of nested hash refs
by Limbic~Region (Chancellor) on Feb 29, 2004 at 13:25 UTC | |
by doran (Deacon) on Mar 01, 2004 at 07:06 UTC | |
by Limbic~Region (Chancellor) on Mar 01, 2004 at 14:40 UTC | |
|
Re: Re: Sorting values of nested hash refs
by doran (Deacon) on Mar 01, 2004 at 06:31 UTC |