On Apr 15, Dave Chappell said:

>I open 1 file for reading and another for writing. The script examines each
>line of the file being read and if any of the following words or digits
>matches, skip the line and go to the next. Write everything else to another
>file. 
>
>while (<IN>) {
>  next if /(\d5|\d100|\d25|this|could|get|very|long)/;
>  print OUT;
>}

You'll probably want to do it that way, but you might want to organize the
regex such that it does as little redundant work as possible.  Consider:

  next if /this|that|these|those|them|thin/;

Each of those words starts with "th", and two with "thi" and "the".  It
would be better, in the long run, to write

  next if /th(i(s|n)|e(se|m)|at|ose)/;

Although it might look a little messier, it's not that bad.  But this is
probably not the type of thing you need to be optimizing.  Your code now
is fine.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to