I asked this same question..
The second way would be more efficent if you put the pattern that will match
more often first/at the top.

> -----Original Message-----
> From: Dave Chappell [mailto:[EMAIL PROTECTED]]
> Sent: Monday, April 15, 2002 10:30 AM
> To: [EMAIL PROTECTED]
> Subject: examining a file line-by-line
> 
> 
> Is there a more efficient way of approaching this? 
> 
>  
> 
> 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;
> 
> }
> 
>  
> 
> ....or I can do it this way:
> 
>  
> 
>  
> 
> while (<IN>) {
> 
>             next if /\d5/;
> 
> next if /\d100/;
> 
> next if /\d25/;
> 
> next if /this/;
> 
> next if /could/;
> 
> next if /get/;
> 
> next if /very/;
> 
> next if /long/;
> 
>             
> 
>             print OUT;
> 
> }
> 
>  
> 
> Regards,
> 
>  
> 
> Dave Chappell
> 
>  
> 
>  
> 
>  
> 
> 

----------------------------------------------------------------------------
--------------------
The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


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

Reply via email to