File: abc-pairs.pl

package info (click to toggle)
mcl 1%3A14-137-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 10,704 kB
  • ctags: 5,125
  • sloc: ansic: 53,217; sh: 4,448; perl: 3,967; makefile: 422
file content (41 lines) | stat: -rwxr-xr-x 650 bytes parent folder | download | duplicates (5)
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";
   }
}