(C) 2003, Tim Maher 1-12 www.TeachMePerl.com Enhanced Perl Grep #! /usr/bin/perl -wlns our ($i, $m, $s, $p); # avoid "used only once" BEGIN { # Executed before input is processed $X=""; # fill with options $i and $X.='i' ; # ignore case $m and $X.='m' ; # multi-line mode $s and $X.='s' ; # single-line mode $p and $/="" ; # paragaph mode $pattern=shift ; # args now files $id_files = @ARGV > 1 ; # show filenames? $command = "/$pattern/$X" ; } if ( eval $command ) { $id_files and print "$ARGV:" ; print ; # show matching record }