(C) 2003, Tim Maher 1-24 www.TeachMePerl.com veperlgrep #! /usr/bin/perl -wlns our ($e,$i,$m,$s,$p); # avoid "used only once" BEGIN { $U="Usage: $0 [-eimsp] 'RE' f1.." ; @ARGV >= 2 or die "$U"; $X="" ; $e and $^I=$$; # file-ext is PID $i and $X.='i'; # ignore case $m and $X.='m'; # multi-line mode $s and $X.='s'; # single-line mode $p and $/=""; # paragaph mode $On=`tput smso`; $Off=`tput rmso`; $RE=shift; $command=" s/$RE/$On\$&$Off/g$X "; $prefix = @ARGV > 1; # showing filenames? } if (eval $command) { $prefix and print "$ARGV:"; print; }