in reply to perl grep clone

# 5 0 5 0 5 7 $p=shift;print grep/$p/,<>;

and works for any number of files as well as STDIN

However, the content of all the files will be "slurped" into memory because <> is in list context.

To read line by line:

# 5 0 5 0 5 0 2 $p=shift;while(<>){print if/$p/}

Replies are listed 'Best First'.
Re^2: perl grep clone
by pythondude (Initiate) on Apr 02, 2016 at 00:05 UTC
    I like this answer because It still allows the default filenames on commandline arguments to stdin behavior with <>.