in reply to Hash Value via Data::Dumper

You need a loop over the users, I would think:

for $uid (keys %users) { my $count = @{$users{$uid}}; # etc ... }

Replies are listed 'Best First'.
Re^2: Hash Value via Data::Dumper
by johnrein55 (Novice) on Jun 12, 2013 at 12:06 UTC
    Hi, I am beginner, however tried to come up with something. Could you please suggest on my existing code, or a better way of doing it? Thanks, John
Re^2: Hash Value via Data::Dumper
by johnrein55 (Novice) on Jun 12, 2013 at 15:12 UTC
    Any suggestion you've for
    if (defined $users{$conn1})

      As far as I can see you don't need that. You already have $count which is the number of connections for a given user, just print if it is larger than 3.

        Yes, no issue on that, however the count has to be within the loop, as it performs a lookup over the %users hash. This is the most import piece, as it establishes the relationship.

        if (defined $users{$conn1}) # search to check existing of conn to uid. { if ($num{$uid} > 1) { print "bad users"; ## user group add command. } }
        There also my query is pending. I really need to finish this up.

        Log File:

        [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
        Here is the code :
        #!/usr/bin/perl use strict; use warnings; my %hash; my $conn; open my $fh, '<', 'file1.txt' or die "failed: $!"; while (<$fh>) { while ( /conn=(\d+).*uid=(.*?),/g ) { $conn = $1; $hash{$conn} = $2; } my ($conn1) = map { $_ =~ /conn=(\d+).*SRCH=Q/ } <$fh>; print "$hash{$conn} => $conn\n" if grep /$conn1/, keys %hash; } close $fh;