Hi all. I'm trying to remove lines from a file based on the lines given in another file. My code actually works but stops with an error

Can't find Unicode property definition "R" at c:/remove.pl line 23, <CURRENTDAT> line 8.

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_Shares.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 users).

Any help appreciated. I also tried VBS got close but what a nightmare!

# Open the file containing the matches to remove open(BADSHARES, "c:/testy/Bad_Shares.txt"); @BadShares = <BADSHARES>; # Open the file/s to remove these matches from open(CURRENTDAT, "c:/testy/test.dat"); @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 ($i = 0; $i < scalar(@BadShares); $i++) { # If the current line in the DAT matches any line in the file to m +atch set that line to zero # print "$DatLines[$a] $BadShares[$i]"; if ($DatLines[$a] =~ m/($BadShares[$i])/i) { print "MATCH $DatLines[$a] $BadShares[$i]"; # $DatLines[$a]="" } } }

In reply to Remove lines from a list of files based on those in a given file by Paws_of_Iron

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.