Well I'm convinced I'm using the split function wrong if my output is anything to go by. What I want to do is take lines formed exactly like the following (with the exception that there's multiple spaces between the columns in the real thing):
10.1.3.4 08/13/2003 14:18:30 PASSED 18.9.27.99 08/13/2003 16:08:44 PASSED 212.18.94.22 08/13/2003 17:29:06 PASSED
And have the script look at it as 5 different columns (or parts), so I could take the user IP addresses, and count the individual instances of them. As in if the IP address 10.1.3.4 appeared 12 times in the document, I want it to output that to the screen; if 18.9.27.99 appeared 4 times, tell me, etc. They're all grouped chronologically, so the loop would have to go through the document several times until it got every instance of the IP's. I know it's possible but I can't exactly put the picture together.
I'm definitely not sure how to get it to store all the instances in different variables. I'm probably overextending my abilities being a total newbie at this, but I'd appreciate any help or direction anyone could offer. Thanks!
10.1.3.4 08/13/2003 14:18:30 PASSED 18.9.27.99 08/13/2003 16:08:44 PASSED 212.18.94.22 08/13/2003 17:29:06 PASSED
And have the script look at it as 5 different columns (or parts), so I could take the user IP addresses, and count the individual instances of them. As in if the IP address 10.1.3.4 appeared 12 times in the document, I want it to output that to the screen; if 18.9.27.99 appeared 4 times, tell me, etc. They're all grouped chronologically, so the loop would have to go through the document several times until it got every instance of the IP's. I know it's possible but I can't exactly put the picture together.
Code:
my $User;
my $Dd;
my $Tt;
my $Ap;
my $Dest;
print "Which file: ";
$TheDB = <STDIN>;
chomp($TheDB);
# Open the database file but quit if it doesn't exist
open(INDB, $TheDB) or die "The database $TheDB could " .
"not be found.\n";
while(<INDB>) {
$TheRec = $_;
chomp($TheRec);
($User, $Dd, $Tt, $Ap, $Dest) = split(/\t/, $TheRec, 2);
$SuccessCount++;
print "$User "
} # End of while(<INDB>)
if($SuccessCount == 0) { print "No records found.\n" }
else { print "$SuccessCount records found.\n" }
print "Program finished.\n";
I'm definitely not sure how to get it to store all the instances in different variables. I'm probably overextending my abilities being a total newbie at this, but I'd appreciate any help or direction anyone could offer. Thanks!