# *perl* use strict; use warnings; use Getopt::Std; our ($opt_n, $opt_g); getopt('n'); if (! $opt_n || ! $opt_g) { print "usage: $0 -n numberlist -g globpattern\n" . " where numberlist are numbers separated by commas,\n" . " e.g. -n 1203,0815,22222\n"; exit; } my %matches; $matches{$_} = 0 for split /,/, $opt_n; $opt_n =~ s/,/|/g; my $re = qr{\b($opt_n)\b}; @ARGV = <$opt_g>; # set @ARGV to found files while(<>) { my @m; @m = $_ =~ /$re/g and @matches{@m} = (1) x @m and print "$ARGV $_"; } my @nomatch = grep { ! $matches{$_} } keys %matches; if(@nomatch) { print "$_ not matched\n" for @nomatch; } #### C:\some\path>perl match.pl -n 1203,1204,1207 -g c:/perl64/myfiles/*