use strict; use warnings; #Program to read the command line report file; and extract the virus detection name for a file. my $cmdrep = "d:/eitv10cm_cln.rep"; my $fname = "D:\\EITV10CM\\base\\repair\\Companion_Repair\\File2SelfExt\\F2SEXT.COM"; my ($found,$virusname,$flag,$i); my (@dirtemp) = split /:/,$fname; #declared the variables with my shift @dirtemp; my $filepath; foreach my $itemp ( @dirtemp ) { $filepath .= $itemp; } while () { chomp; $_ =~ s/\w\://; #you are missing this line next if $_ !~ /^\Q$filepath\E/i; #else remove the anchor chomp($_); /\s\.{3}\s(.*)/; $found = $1; print "$found\n"; if ($found eq "is OK.") { $virusname = "OK"; print "The virus detection name is $virusname\n"; last; } if ($found =~ /^Found: (.*?) NOT a virus[.]/) { $virusname = $1; print "The virus detection name is $virusname\n"; last; } elsif ($found =~ /^Found the (.*?) (virus|trojan) !!!/) { $virusname = $1; print "The virus detection names is $virusname\n"; last; } elsif ($found =~ /^Found potentially unwanted program (.*?)[.]/) { $virusname = $1; print "PuPs $virusname \n"; last; } elsif ($found =~ /Found (virus or variant|application) (.*?)( !!!|[.])/) { $virusname = $2; print "Virus or variant $virusname \n \n"; $flag =1; last; } } __DATA__ C:\EITV10CM\base\repair\Companion_Repair\File2File\F2F.COM ... is OK. C:\EITV10CM\base\repair\Companion_Repair\File2SelfExt\F2SEXT.CMP ... is OK. C:\EITV10CM\base\repair\Companion_Repair\File2SelfExt\F2SEXT.COM ... Found the CMPAN/File2SelfExt virus !!! The virus has been removed from the file. Checking for another virus in the file ... C:\EITV10CM\base\repair\Companion_Repair\File2SelfExt\F2SEXT.COM ... is OK output: ------- Found the CMPAN/File2SelfExt virus !!! The virus detection names is CMPAN/File2SelfExt