in reply to Re^4: Hash Value via Data::Dumper
in thread Hash Value via Data::Dumper
Hope this helps:
use strict; use warnings; use Data::Dumper; my %users; my %searches; #open my $fh, '<', 'file1.txt' or die "failed: $!"; while (<DATA>) { # I use DATA handle instead of $fh for convenience if( /BIND/ ) { my( $conn, $uid ) = /conn=(\d+).*uid=(.*?),/; $users{$uid} = $conn; } if( /SRCH=Q/ ) { my ($timestamp, $conn) = /\[(.*?)\] conn=(\d+)/; push @{$searches{$conn}}, $timestamp; } } #close $fh; for my $user (keys %users) { print "User $user had ".scalar( @{$searches{$users{$user}}} ). +" searches on connection ".$users{$user}."\n"; } print Dumper \%users; print Dumper \%searches; __DATA__ [04/Jun/2013:13:06:13 -0600] conn=13570 op=14 msgId=13 - BIND dn="uid= +xyz123,ou=People,o=xyz.com" method=128 version=3 [04/Jun/2013:15:06:13 -0600] conn=13570 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:15:06:14 -0600] conn=13570 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:15:06:15 -0600] conn=13570 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:15:06:16 -0600] conn=13570 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:15:06:17 -0600] conn=13570 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:17:06:13 -0600] conn=13571 op=14 msgId=13 - BIND dn="uid= +xyz456,ou=People,o=xyz.com" method=128 version=3 [04/Jun/2013:18:06:17 -0600] conn=13571 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:18:06:17 -0600] conn=13571 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:18:06:17 -0600] conn=13571 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:18:06:17 -0600] conn=13571 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q [04/Jun/2013:18:06:17 -0600] conn=13571 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139 SRCH=Q
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Hash Value via Data::Dumper
by Anonymous Monk on Jun 14, 2013 at 09:29 UTC | |
by hdb (Monsignor) on Jun 14, 2013 at 09:37 UTC | |
by johnrein55 (Novice) on Jun 14, 2013 at 14:43 UTC | |
by hdb (Monsignor) on Jun 14, 2013 at 17:53 UTC | |
by johnrein55 (Novice) on Jun 14, 2013 at 18:32 UTC |