On Mon, Jul 20, 2015 at 6:19 AM, Vincent Lequertier <[email protected]> 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
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/