#!d:\perl\bin\perl.exe use IO::File; use File::Find; find ({ wanted => \&grepfile }, 'F:/'); exit 0; sub grepfile { my ($dev, $ino, $mode, $nlink, $uid, $gid); return unless ($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_); return unless -f _; my $fh = IO::File->new($_, "r"); my @match = grep { /sample\.exe/i } <$fh>; $fh->close; unlink $File::Find::name if scalar @match; # print $File::Find::name, "\n" if scalar @match; return; }