#!/usr/bin/perl use strict; $hits=0; $string_to_find="string"; $file = "filename"; open (LOGFILE, $file); while($line = ) { if ($line =~ /$string_to_find/i) { $hits++; print "$line"; print scalar ; } } close(LOGFILE);