Perl works better than grep because the grep statement you give below does
not find any instances of the pattern and perl finds quite a few. I'm using
Cygwin on Win2003Server. Since there is something obviously wrong with my
cygwin implementation of grep, how do I get the file names with perl?

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" if/^ *END *$/; }}' *.f

Thanks,
Siegfried

-----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 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

grep -n '^ *END *$' *.f


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




-- 
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