SHORT STORY ALL FIXED THANKS Sorry for horrible formatting but Perl Monks makes posting a pain (all those tages I cant remember hidden in the site so finding how to post takes 10 minutes I'll never get back each time). Thanks for taking a look. Here is what I've found. The file that contains the matches has loads of drives like this \\HOFIL01\CALDWELLS$ \\GEMINI1\CAMBRIDGE$ \\GEMINI1\ADMIN \\GEMINI2\CONFERENCE \\HOFIL02\PROJECT \\HOIFL02\CURRFUNC \\HOFIL01\CAPELLAC$ \\HOFIL01\CARKEEKF$ When the script hits a line like \\HOFIL02\PROJECT it breaks. If I change it to \\HOFAL02\PROJECT or \\HOFIL02\PROJECT THIS or \\HOFIL02\PZ (but no lower letter than Z) it will work (or stop on the next \\hofil02\p(a-y) (but if it ended in $ it was ok?! in horror at the oddness of this I simply removed all \,$ and spaces from the variables before comparing them which worked fine. How bizzar? What would cause only lines starting in \\hofil02\p(a-z)$ to cause an issue? Also for a start I just removed any space from the variables. Then it would stop on half the lines starting in \\hofil02\p(a-z)???$ (eg \\hofil01\pathis$). The Dat file that these patterns where being matched against looked like this. [NATIONAL OFFICE] floor=2 h:=\\moent14\username$ i:=\\aknt1\operations The dats had no space on the end of the drive entries but the matching file did. All very odd. My Perl was always bad and now it is rust so here is my current full script (no laughing please it works nicely). I'll mod it up to output the changed files (and eventually to replace the existing ones after some more testing). # Once more into the Perl Dear Friends Bruce Taylor :: Datacom Consulting # # Search all MOE DAT files in a given directory, remove any lines found in another given file use File::Find; # Built in perl function that finds files in directories (find - traverse a file tree) # http://www.perldoc.com/perl5.6.1/lib/File/Find.html $feeddir = @ARGV[0]; # @ARGV is the built in perl array that is feed to the script from the command line $feeddir =~ s/\\/\//; # If the dir is given using \ (like c:\temp) then subsitute all \ for /'s if ($feeddir =~ "") { system("cls"); print "\n\n\n\nNo directory specified\n\n"; print "You need to specify a driectory to search down\n"; print "EG... SearchReplace.pl c:\\TEMP\DATS\n\n\n\n\n"; die; } chdir("$feeddir"); # Change working directory to the now corrected directory given on the command line find(\&wanted, "$feeddir"); # use the built in find command with the wanted subroutine and send it the $feeddir variable sub wanted # the wanted subrouting is used to select only .dat files(further) down and set the filename { # the { is used to start a code block /\.DAT$/i or return; # Nab only DATS or go to the next file $filename = $File::Find::name; # set $filename variable to full path\name ie c:\temp\dats\datfile.dat &Details($filename); # so we have the file and then feed that into the Details sub/sub routine } sub Details { # the Details sub $file = shift; # Open the file containing the matches to remove open(BADSHARES, "c:/testy/Bad_Shares.txt"); @BadShares = ; close BADSHARES; # Open the file/s to remove these matches from open(CURRENTDAT, "$file"); @DatLines = ; close CURRENTDAT; # For each line of the file containing the matches to remove for ($a = 0; $a < scalar(@DatLines); $a++) { # Go through each line of the file you want to remove the matches from for ($i = 0; $i < scalar(@BadShares); $i++) { # Remove any \, $ or space from the line being worked on from each file (seems to upset perl in unnatural ways) $BadShares[$i] =~ s/ //g; $BadShares[$i] =~ s/\\//g; $BadShares[$i] =~ s/\$//g; $DatLines[$a] =~ s/ //g; $DatLines[$a] =~ s/\\//g; $DatLines[$a] =~ s/\$//g; next if (!($DatLines[$a] =~ m/($BadShares[$i])/i)); chomp $DatLines[$a]; chomp $BadShares[$i]; print "$file $DatLines[$a] $a $BadShares[$i] $i\n"; } } }