#!/usr/bin/perl use warnings; use strict; use File::Basename; if (@ARGV < 2) { print "usage: ", basename($0), " \n"; exit 2; } my $pattern = shift; for my $string (@ARGV) { if (my @matches = $string =~ /$pattern/) { print "\e[0;32mmatches:\e[0m "; if ($#- != 0) { for my $match (@matches) { print $match; } } else { print "$&"; } print "\n"; } else { print "\e[0;31mno match\e[0m\n"; } }