use strict; use warnings; my $file = $ARGV[0]; my $purpose = $ARGV[1]; open( FILE, "$file" ) or die "Can't open $file: $!"; while ( ) { If ($purpose = "sqlerrors") { print if ( /SQL Error:/i .. m{^\s*$}); } If ($purpose = "othererrors") { print if ( /OTHER Error:/i .. m{^\s*$}); } If ($purpose = "missingfile") { print if ( /Missing File:/i .. m{^\s*$}); } } close FILE;