Another approach using Tie::IxHash: use Tie::IxHash; use Data::Dumper; use feature 'say';
my @ip = (...) my %hash = (...); tie( my %ordered, 'Tie::IxHash', map { ( $_,[ ] ) } @ip ); while ( my($key,$value) = each %hash ) { push @{$ordered{$value->{ip}}}, {$key,$value}; } say Dumper \%ordered; Leaving exact details of printing as an exercise for reader... -- Charles DeRykus On Fri, Jul 17, 2015 at 6:11 AM, Vincent Lequertier <s...@riseup.net> wrote: > Hi, > > I have the following structure : > > $hash{$date} = { > 'ip' => $ip, > 'action' => $action, > }; > > witch produce data like : > > $VAR1 = '[15/Jul/2015:10:30:03 +0200]'; > $VAR2 = { > 'ip' => 'xxx.xxx.xxx.xxx', > 'action' => 'GET xxx' > }; > > and an array of ip addresses, say @ip > > My question is how can I display the content of %hash in the order of @ip, > assuming %hash has the same length as @ip ? > > Thank you > > -- > Vincent Lequertier > vincentlequertier.tk > > -- > To unsubscribe, e-mail: beginners-unsubscr...@perl.org > For additional commands, e-mail: beginners-h...@perl.org > http://learn.perl.org/ > > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/