Perl: the Markov chain saw | |
PerlMonks |
Re: perl grep clone (CLI & perlrun)by LanX (Saint) |
on Apr 02, 2016 at 12:07 UTC ( [id://1159363]=note: print w/replies, xml ) | Need Help?? |
I have the impression your motivation comes from the desire to emulate grep from command line. So maybe you want to have a look at -l -a -n -e -p ...(and so on) options in perlrun ?
e.g.
causes Perl to assume the following loop around your program, which makes it iterate over filename arguments somewhat like sed -n or awk:
Note that the lines are not printed by default. See -p to have lines printed. If a file named by an argument cannot be opened for some reason, Perl warns you about it and moves on to the next file.
updateAs replacement for grep PATTERN * try perl -ne'/PATTERN/&&print' * for a start. :)
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|