Le 2015-07-20 16:49, Charles DeRykus a écrit :
On Mon, Jul 20, 2015 at 6:19 AM, Vincent Lequertier <s...@riseup.net> 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
$ordered{'xxx.xxx.xxx.xxx'}[0]{'[15/Jul/2015:10:30:03 +0200]'}{action};

But I don't find how to get the dates e.g. '[15/Jul/2015:10:30:03 +0200]'

Here is what I've tried:

tie( my %ordered, 'Tie::IxHash', map { ( $_,[ ] ) }   @ip );

while ( my($key,$value) = each %hash ) {
    push @{$ordered{$value->{ip}}}, {$key, $value};
}
#print Dumper \%ordered;
my $i = 1;
for my $key (keys %ordered) {
    print "ip number $i : $key\n";
    for my $entry (@{$ordered{$key}}) {
        print $entry . "\n";
    }
    ++$i;
}


Depending on output preference and level of detail, one possibility:

...
   for  foreach my $entry ( @{$ordered{$ip}} ) {
        while ( my($date, $data) = each %{$entry} ) {
              say join( " ","$date:", $data->{ip}, $data->{action} );
        }
   }

--
Charles DeRykus


Thanks a lot, now I get what I need. Thanks to those who helped me as well. Great community

--
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/


Reply via email to