in reply to Remove lines from a list of files based on those in a given file
Most likely it is that you need to quote the BadShares interpolated string: m/(\Q$BadShares[$i]\E)/i. However, the code snippet you have given is not ameniable to us reproducing your error. Try plugging suitable data into:
use strict; use warnings; open tempFile, '>', "test.dat"; print tempFile <<TEMP; it is always the last line). Line 23 is the pattern match part of the +code. If is my early test script before I get it to go through a list of files +in a TEMP close tempFile; my @BadShares = <DATA>; # Open the file/s to remove these matches from open CURRENTDAT, '<', "test.dat"; my @DatLines = <CURRENTDAT>; # For each line in the file to match from for ($a = 0; $a < scalar(@DatLines); $a++) { # Go through each line of the file to remove these matches from for (my $i = 0; $i < scalar(@BadShares); $i++) { # If the current line in the DAT matches any line in the file +to match set # that line to zero if ($DatLines[$a] =~ m/(\Q$BadShares[$i]\E)/i) { print "MATCH $DatLines[$a] $BadShares[$i]"; } } } __DATA__ Line 8 is the last line in the file test.dat (this error changes if I +add lines it is always the last line). Line 23 is the pattern match part of the +code. If I print the lines as it goes it is less than half way through Bad_Shar +es.TXT and the line changes as I add lines to test.dat (running out of memory +?). This is my early test script before I get it to go through a list of files +in a given directory (lots of DATs containing drives to map for specific us +ers).
Prints:
MATCH it is always the last line). Line 23 is the pattern match part +of the code. If it is always the last line). Line 23 is the pattern match part +of the code. If MATCH is my early test script before I get it to go through a list of + files in a is my early test script before I get it to go through a list of + files in a
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Remove lines from a list of files based on those in a given file
by Paws_of_Iron (Initiate) on Jan 31, 2006 at 02:24 UTC | |
by GrandFather (Saint) on Jan 31, 2006 at 02:36 UTC | |
by Paws_of_Iron (Initiate) on Jan 31, 2006 at 03:47 UTC |