#!/usr/bin/perl my $word = shift; while (<>) { s/\Q$word\E/\e[31m$word\e[0m/g; print; } __END__ #!/usr/bin/perl -s # jac $usage = " Usage: highlight [-h -l -u -i] EXPR1 EXPR2 ... Options: -h display this help and exit -i insensite search -l lower case letters of expressions -u upper case letter of expressions see perldoc highlight for more information "; if ($h) { print $usage; exit } if ($l && $u) { die("you can only choose one of -u and -l.\n") } @e = shift || die("at least one expression is needed.\n"); while ($e = shift) { push @e, $e } unless ($u || $l) { $e1 = ">>>"; $e2 = "<<<" } $e = join ("|", @e); while (<>) { if ($i) { s!$e! $t = $&; if ($u) {$t =~ tr/a-záàãâäéèêëíìîïóòõôöúùûüç/A-ZÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ/} if ($l) {$t =~ tr/A-ZÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ/a-záàãâäéèêëíìîïóòõôöúùûüç/} "${e1}${t}$e2" !gei; } else { s!$e! $t = $&; if ($u) {$t =~ tr/a-záàãâäéèêëíìîïóòõôöúùûüç/A-ZÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ/} if ($l) {$t =~ tr/A-ZÁÀÃÂÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ/a-záàãâäéèêëíìîïóòõôöúùûüç/} "${e1}${t}$e2" !ge } print } __END__ =head1 NAME highlight - highlights expressions =head1 SYNOPSIS highlight [OPTIONS] EXPR1 EXPR2 ... =head1 DESCRIPTION highlight marks matches of given expressions =head1 USAGE highlight [ -h | -u | -l ] [ -i ] EXPR1 EXPR2 ... =head1 OPTIONS =head2 -h displays an help text =head2 -i insensitive search =head2 -l highlighting is done by lower casing all letters inside matches =head2 -u highlighting is done by upper casing all letters inside matches =head1 BUG REPORT / COMMENTS / SUGESTIONS all of this should be send to the author, at his current e-mail address (see section below). =head1 AUTHOR Jose' Alves de Castro =cut