$LOGFILE = 'c:\perl\data\file1.txt'; open(LOGFILE) or die("Could not open log file."); $mycount = 0; foreach $line () { chomp($line); if ($line eq 'x.x'){ $mycount++; } } print "Found a total of $mycount occurances of x.x!\n"; close(LOGFILE);