1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#!/usr/local/bin/perl
use strict;
use Getopt::Long;
my $cmode = 'extend';
my $rmode = 'extend';
my $etcai = 0;
if
(! GetOptions
( "cmode=s" => \$cmode
, "rmode=s" => \$rmode
, "etcai" => \$etcai
)
)
{ print STDERR "option processing failed\n";
exit(1);
}
my $cstrict = $cmode eq 'restrict';
my $rstrict = $rmode eq 'restrict';
my $ai = 0;
while (<>) {
chomp;
my @F = split;
my $l = $etcai ? $ai : shift @F;
next if $cstrict && !$etcai && lc($l) ne $l;
my @f = grep { !$rstrict || lc($_) eq $_ } @F;
next if $etcai && !@f;
$ai++;
for (@f) {
print "$l\t$_\n";
}
}
|