Re: How to reinvent grep in perl?

2007-10-08 Thread Jenda Krynicky
From: Chas. Owens [EMAIL PROTECTED] On 10/3/07, Jonathan Lang [EMAIL PROTECTED] wrote: snip Chas shows one possibility. However, that approach generally involves slurping the entire file into the perl script, applying the regex to the whole thing, and then spitting the result out again.

Re: How to reinvent grep in perl?

2007-10-08 Thread Chas. Owens
On 10/8/07, Jenda Krynicky [EMAIL PROTECTED] wrote: From: Chas. Owens [EMAIL PROTECTED] On 10/3/07, Jonathan Lang [EMAIL PROTECTED] wrote: snip Chas shows one possibility. However, that approach generally involves slurping the entire file into the perl script, applying the regex to

Re: How to reinvent grep in perl?

2007-10-05 Thread John W. Krahn
siegfried wrote: ?? wrote: siegfried wrote: I need to search large amounts of source code and grep is not doing the job. The problem is that I keep matching stuff in the comments of the C++/Java/Perl/Groovy/Javascript source code. Can someone give me some hints on where I might start

RE: How to reinvent grep in perl?

2007-10-04 Thread siegfried
siegfried wrote: I need to search large amounts of source code and grep is not doing the job. The problem is that I keep matching stuff in the comments of the C++/Java/Perl/Groovy/Javascript source code. Can someone give me some hints on where I might start on rewriting grep in perl so that

Re: How to reinvent grep in perl?

2007-10-04 Thread Jonathan Lang
siegfried wrote: Thanks, but if I am piping from stdin to stdout I see two problems: (1) how do I implement the -n flags that tell me the line number and file name where the matches are Well, as long as you're only piping one file at a time, the line number part isn't a problem; but I see

How to reinvent grep in perl?

2007-10-03 Thread siegfried
I need to search large amounts of source code and grep is not doing the job. The problem is that I keep matching stuff in the comments of the C++/Java/Perl/Groovy/Javascript source code. Can someone give me some hints on where I might start on rewriting grep in perl so that it ignores the

Re: How to reinvent grep in perl?

2007-10-03 Thread jm
by strange coincidence, i just picked up where i had left off reading Minimal Perl by Tim Maher, which goes into some detail about replacing grep (among other functionalities) with either perl one-liners or scripts, depending on preference/need. this book may well be worth your time and money.

Re: How to reinvent grep in perl?

2007-10-03 Thread Chas. Owens
On 10/3/07, siegfried [EMAIL PROTECTED] wrote: I need to search large amounts of source code and grep is not doing the job. The problem is that I keep matching stuff in the comments of the C++/Java/Perl/Groovy/Javascript source code. Can someone give me some hints on where I might start on

Re: How to reinvent grep in perl?

2007-10-03 Thread Chas. Owens
On 10/3/07, Jonathan Lang [EMAIL PROTECTED] wrote: snip Chas shows one possibility. However, that approach generally involves slurping the entire file into the perl script, applying the regex to the whole thing, and then spitting the result out again. From what I understand, this generally

Re: How to reinvent grep in perl?

2007-10-03 Thread Jonathan Lang
siegfried wrote: I need to search large amounts of source code and grep is not doing the job. The problem is that I keep matching stuff in the comments of the C++/Java/Perl/Groovy/Javascript source code. Can someone give me some hints on where I might start on rewriting grep in perl so that

Re: How to reinvent grep with perl? (OT: Cygwin grep)

2004-10-10 Thread Harry Putnam
Bakken, Luke [EMAIL PROTECTED] writes: Voila. That's most likely your problem - a mismatch between line endings and Cygwin mount point type. And in case you hadn't seen them before... there are at least a few sets of unix tools for dos/windows. Cygwin maybe the best known but I've used Uwin

RE: How to reinvent grep with perl? (OT: Cygwin grep)

2004-10-10 Thread Bakken, Luke
Voila. That's most likely your problem - a mismatch between line endings and Cygwin mount point type. And in case you hadn't seen them before... there are at least a few sets of unix tools for dos/windows. Cygwin maybe the best known but I've used Uwin myself for sometime and never

How to reinvent grep with perl?

2004-10-09 Thread Siegfried Heintze
My man pages and info pages are not working well and I cannot figure out how to make grep search for a certain pattern. I even tried egrep and fgrep. So how do I reinvent grep with perl? Here is my attempt: perl -n -e 'print $. $_ if /^ *END *$/' *.f This works better than grep, except for

Re: How to reinvent grep with perl?

2004-10-09 Thread Andrew Gaffney
Siegfried Heintze wrote: My man pages and info pages are not working well and I cannot figure out how to make grep search for a certain pattern. I even tried egrep and fgrep. So how do I reinvent grep with perl? Here is my attempt: There's no need. When you do 'man whatever', you can hit '/', type

Re: How to reinvent grep with perl?

2004-10-09 Thread Andrew Gaffney
Siegfried Heintze wrote: Andrew, Thanks. When I hit n to go to the next page, it says No previous regular expression (press RETURN). So I can only display the first page. I have it expanded to the full screen but I still cannot see the portion of the display that tells me how to use extended

Re: How to reinvent grep with perl?

2004-10-09 Thread Harry Putnam
Siegfried Heintze [EMAIL PROTECTED] writes: My man pages and info pages are not working well and I cannot figure out how to make grep search for a certain pattern. I even tried egrep and fgrep. So how do I reinvent grep with perl? Here is my attempt: perl -n -e 'print $. $_ if /^ *END

Re: How to reinvent grep with perl?

2004-10-09 Thread Harry Putnam
Siegfried Heintze [EMAIL PROTECTED] writes: This works better than grep, except for the fact it does not print the file name. How can I make perl print the file file name? How is it better than grep? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL

RE: How to reinvent grep with perl?

2004-10-09 Thread Siegfried Heintze
-Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Harry Putnam Sent: Saturday, October 09, 2004 4:33 PM To: [EMAIL PROTECTED] Subject: Re: How to reinvent grep with perl? Siegfried Heintze [EMAIL PROTECTED] writes: My man pages and info pages are not working well and I cannot

Re: How to reinvent grep with perl?

2004-10-09 Thread Harry Putnam
Siegfried Heintze [EMAIL PROTECTED] writes: This, works, but it sure is ugly. Is there not an easier way to do this with perl? perl -e'@ARGV = (-) unless @ARGV; while(@ARGV){ $ARGV= shift @ARGV; if(!open(ARGV, $ARGV)){ warn Cannot open $ARGV: $!\n; next;} while (ARGV){ print $ARGV:$.:$_\n