Re: Display a hash in the order of an array

2015-07-21 Thread Vincent Lequertier
Le 2015-07-20 16:49, Charles DeRykus a écrit : On Mon, Jul 20, 2015 at 6:19 AM, Vincent Lequertier wrote: Thank you for the help, Charles! Unfortunately, I'm not able to figure out how to access the element of %ordered, despite some diggings in the perldoc (http://perldoc.perl.org/perldsc.htm

Re: Display a hash in the order of an array

2015-07-20 Thread Charles DeRykus
On Mon, Jul 20, 2015 at 6:19 AM, Vincent Lequertier wrote: > Thank you for the help, Charles! Unfortunately, I'm not able to figure out > how to access the element of %ordered, despite some diggings in the perldoc > (http://perldoc.perl.org/perldsc.html). > I can print a single element with print

Re: Display a hash in the order of an array

2015-07-20 Thread Vincent Lequertier
Thank you for the help, Charles! Unfortunately, I'm not able to figure out how to access the element of %ordered, despite some diggings in the perldoc (http://perldoc.perl.org/perldsc.html). I can print a single element with print $ordered{'xxx.xxx.xxx.xxx'}[0]{'[15/Jul/2015:10:30:03 +0200]'}{ac

Re: Display a hash in the order of an array

2015-07-20 Thread nosettle
> 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.x

Re: Display a hash in the order of an array

2015-07-20 Thread Vincent Lequertier
Thank you, I thought about transforming my hash like your function transform_date_logs_to_ip_logs does but didn't found the way. I'm now trying to understand exactly how that works :-) -- Vincent Lequertier vincentlequertier.tk Le 2015-07-17 16:40, Brandon McCaig a écrit : Vincent: On Fri,

Re: Display a hash in the order of an array

2015-07-20 Thread Shlomi Fish
Hi Vincent, On Mon, 20 Jul 2015 09:18:33 +0200 Vincent Lequertier wrote: > Thank you for the help, but this does not work. We needa pass the ip > addresses to the sorting function, because actually the keys of the hash > are the dates > > $VAR1 = '[15/Jul/2015:10:30:03 +0200]'; > $VAR2 = { >

Re: Display a hash in the order of an array

2015-07-20 Thread Илья Рассадин
Why you don't want rebuild you hash into another hash with ip address as a key? Yes, it will cost you additional memory and runtime but it will be more convenient and easy to understand, support and modificate. If memory is not a problem, i think it's best choice in your case. See https://gist.gi

Re: Display a hash in the order of an array

2015-07-20 Thread Vincent Lequertier
Thank you for the help, but this does not work. We needa pass the ip addresses to the sorting function, because actually the keys of the hash are the dates $VAR1 = '[15/Jul/2015:10:30:03 +0200]'; $VAR2 = { 'ip' => 'xxx.xxx.xxx.xxx', 'action' => 'GET xxx' }; T

Re: Display a hash in the order of an array

2015-07-17 Thread Charles DeRykus
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 \%orde

Re: Display a hash in the order of an array

2015-07-17 Thread Brandon McCaig
On Fri, Jul 17, 2015 at 10:40 AM, Brandon McCaig wrote: > for my $i (0..4) { Errr, 0..3. >_> Regards, -- Brandon McCaig Castopulence Software Blog perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }. q{Vg qbrfa'\''g nyjnlf fbhaq gung

Re: Display a hash in the order of an array

2015-07-17 Thread Brandon McCaig
Vincent: On Fri, Jul 17, 2015 at 9:11 AM, Vincent Lequertier wrote: > Hi, Hello, > I have the following structure : > > $hash{$date} = { > 'ip' => $ip, > 'action' => $action, > }; > > witch produce data like : > > $VAR1 = '[15/Jul/20

Re: Display a hash in the order of an array

2015-07-17 Thread Shawn H Corey
On Fri, 17 Jul 2015 15:11:13 +0200 Vincent Lequertier wrote: > Hi, > > I have the following structure : > > $hash{$date} = { > 'ip' => $ip, > 'action' => $action, > }; > > witch produce data like : > > $VAR1 = '[15/Jul/2015:10:3