Please bottom post...

> So you recommend using regular expressions instead of grep..?
> Care to provide an example in this case?
> 

John just provided a good one. Optionally if all you care about is
determining whether a line contains a string it might (I didn't
benchmark it) be faster to use 'index' instead of a regex:

perldoc -f index

My complaint is about the use of shelling out to handle something that
can be easily done programmatically within Perl itself, aka like John
showed using two opens and a simple while with the diamond operator (and
conveniently it has more error checking in it, should be faster, is more
secure, less error prone, and portable!).  To me shelling out is a last
resort, or a quick fix (aka if you have to ask here it isn't quick enough).

http://danconia.org

> -----Original Message-----
> From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
> Sent: Friday, January 16, 2004 3:16 PM
> To: Lewick, Taylor; [EMAIL PROTECTED]
> Subject: RE: Data File, turn fields on mulitple lines into records on
> one li ne.. .
> 
> 
> 
> > Okay, I redid it so it looks like this...
> > 
> > `grep -v "STUFF:STUFF" file1 > file2`;  (I am looking for the string
> > STUFF:STUFF and that didn't work...  but it works via command line...
> > 
> > Any ideas?
> 
> What is the "real" goal?  Aka why are you shelling out to grep in the
> first place?  As a side note you should be using full paths for grep,
> file1, file2, and you should be checking the return code of the command.
> Also it seems silly to use backticks if you are piping STDOUT to a file.
> 
> http://danconia.org
> 
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to