I want to remove a line (which is called from a text file) from another file which may or may not contain the line.
So far I have written this below but it only seems to read the last line of the nosect.txt file and does not do any of the other lines.
\#!/usr/local/bin/perl -w
%Acts = ();
use Getopt::Long;
$time1= time;
&Actsin1;
&Group;
$time2 = time;
$time3 = $time2 - $time1;
print "$time3 seconds\n";
print "finished";
sub Actsin1
{
$filetoopen1 = "c:\\Update\\nosect\.txt";
open (ACTLIST, $filetoopen1) || die "Could not open file $filetoop
+en1 \n";
open (OUTPUT2,">c:\\Update\\Errors.txt") || die "Could not open ou
+tput \n";
dbmopen (%Groups, "c:\\Update\\Groups",0666) || die "Could not ope
+n Acts database\n";
while (<ACTLIST>)
{
$TheLine = $_;
@WordList = "$TheLine";
}
}
sub Group
{
$filetoopen = "c:\\update\\makeme\\statutes\.fff";
open (INPUT, $filetoopen) || die "Could not open file $filetoopen \n";
open (OUTPUT,">c:\\update\\makeme\\newstat.fff") || die "Could not ope
+n output \n";
while (<INPUT>)
{
$TheLine = $_;
if ($TheLine =~ /<RD>[^\n]*Status Compendium<<.JL>/i)
{
$ListPos = 0;
until($ListPos > $#WordList)
{
if ($TheLine eq $WordList[$ListPos])
{
$TheLine = "";
pop(@WordList)
}
$ListPos +=1
}
}
print OUTPUT "$TheLine";
}
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.