johnrein55 has asked for the wisdom of the Perl Monks concerning the following question:
I am getting undefined eror as listed below for the log file when search criteria "SRCH=Q" is missing. Here is the log file and error .
[[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:13:06:13 -0600] conn=13572 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=13572 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= +someoneelse,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:13:06:13 -0600] conn=13573 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=13573 op=14 msgId=15 - RESULT err=0 +tag=101 nentries=48030 etime=139
Here is the error
User xyz123 had 1 searches on connection 13570 User xyz123 had 1 searches on connection 13572 Can't use an undefined value as an ARRAY reference at hash1.pl line 23 +, <IN> line 8.
Here is the code.
use strict; use warnings; use Data::Dumper; my %users; my %searches; while (<DATA>) { # I use DATA handle instead of $fh for convenience if( /BIND/ ) { my( $conn, $uid ) = /conn=(\d+).*uid=(.*?),/; push @{$users{$uid}}, $conn; } if( /SRCH=Q/ ) { my ($timestamp, $conn) = /\[(.*?)\] conn=(\d+)/; push @{$searches{$conn}}, $timestamp; } } for my $user (keys %users) { for my $conn (@{$users{$user}}) { print "User $user had ".scalar( @{$searches{$conn}} ). +" searches on connection $conn\n"; print "\t=> Bad user!\n" if @{$searches{$conn}} > 3; } } print Dumper \%users; print Dumper \%searches;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Undefined Error
by hdb (Monsignor) on Jun 15, 2013 at 07:41 UTC | |
by Anonymous Monk on Jun 15, 2013 at 07:45 UTC | |
by johnrein55 (Novice) on Jun 15, 2013 at 12:01 UTC | |
by poj (Abbot) on Jun 15, 2013 at 12:33 UTC | |
by hdb (Monsignor) on Jun 15, 2013 at 13:33 UTC | |
by johnrein55 (Novice) on Jun 15, 2013 at 14:01 UTC | |
by hdb (Monsignor) on Jun 15, 2013 at 14:05 UTC | |
by poj (Abbot) on Jun 15, 2013 at 14:29 UTC | |
by johnrein55 (Novice) on Jun 15, 2013 at 15:22 UTC | |
by poj (Abbot) on Jun 15, 2013 at 15:46 UTC | |
by hdb (Monsignor) on Jun 15, 2013 at 15:46 UTC | |
by johnrein55 (Novice) on Jun 15, 2013 at 16:22 UTC | |
by poj (Abbot) on Jun 15, 2013 at 17:13 UTC | |
by johnrein55 (Novice) on Jun 15, 2013 at 18:02 UTC | |
by poj (Abbot) on Jun 15, 2013 at 19:07 UTC | |
by johnrein55 (Novice) on Jun 16, 2013 at 07:05 UTC | |
by poj (Abbot) on Jun 16, 2013 at 07:27 UTC | |
by johnrein55 (Novice) on Jun 16, 2013 at 19:21 UTC | |
by johnrein55 (Novice) on Jun 17, 2013 at 20:07 UTC | |
by poj (Abbot) on Jun 18, 2013 at 16:05 UTC | |
by johnrein55 (Novice) on Jun 19, 2013 at 15:10 UTC | |
by johnrein55 (Novice) on Jun 17, 2013 at 13:50 UTC | |
by poj (Abbot) on Jun 17, 2013 at 14:24 UTC | |
by johnrein55 (Novice) on Jun 17, 2013 at 19:46 UTC | |
by poj (Abbot) on Jun 17, 2013 at 20:02 UTC | |
|
Re: Undefined Error (use diagnostics)
by Anonymous Monk on Jun 15, 2013 at 07:42 UTC | |
|
Re: Undefined Error
by poj (Abbot) on Jun 15, 2013 at 07:48 UTC |