in reply to Remove a line of text

A few more things:

  1. First off, after you use strict; like dragonchild recommended, you will notice that @WordList isn't scoped properly. Also, while you have the right idea towards good, modular code by using functions, your functions need to be... functionized. The first one, actsin1, doesn't even really need to be a function at all. In fact, if it wasn't a function, you would no longer have any scoping problems associated with @WordList. Your The second one, Group, should accept the array as an argument. Keeping a tight scope is a good programming practice.
  2. $ListPos +=1 should be $ListPos++. Its much more readable this way - the ++ operator is there for a reason, you know :)
  3. In your file paths, just use a single forward slash - perl will translate the slashes to the correct type based on the system.
  4. This block:
    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";
    can be reduced to:
    if ($TheLine =~ /<RD>[^\n]*Status Compendium<<.JL>/i) { for(my $i=0; $i > @WordList; $i++) { print OUTPUT $TheLine if ($TheLine ne $WordList[$i]) } }

    This is much more easy to read and efficient, since you arent using @WordList after you are done with the program. Give it a whirl.
  5. Instead of explictly timing your program, consider using Benchmark. It is much more accurate

Sorry for being nitpicky, but I felt the urge :) Good Luck!

Replies are listed 'Best First'.
Re: Re: Remove a line of text
by chromatic (Archbishop) on Sep 21, 2001 at 06:08 UTC
    #4 can be reduced to a hash, which is shorter and more efficient yet. Besides that, I doubt the OP wants to print $TheLine for each word it doesn't match.
Re: Re: Remove a line of text
by Larry (Initiate) on Sep 21, 2001 at 07:13 UTC
    Thanks for the help, when I made the changes and ran the script it hangs and returns a null file newstat.fff after about 5 mins. The Statutes.fff file is 400mb. What I am attempting to do is relpace words in the main file from a list of words in a text file (each word is seperated by a line break). I want the output to be a new file which contains all the old text minus the words not wanted.