File: iuniq.pl

package info (click to toggle)
ipolish 1.0.990914-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 1,832 kB
  • sloc: perl: 1,363; sh: 4
file content (34 lines) | stat: -rwxr-xr-x 748 bytes parent folder | download
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
#!/usr/bin/perl -n

#
# autor:Miroslaw.Prywata@fuw.edu.pl
# skrypt analogiczny do uniq (z mniejsz funkcjonalnoci) czcy kolejne
# takie same wpisy w jeden
# wersja:990810
#
if (/^(.*?)\/(\w+)$/){
      $wyr2 = $1;
      $fl2  = "$2";
      }
   elsif (/^(.*)$/){
      $wyr2 = $1;
      $fl2 = "";
      }else{
           die" zla linia:\n$_";
      }

if ($wyr1 eq $wyr2 && $fl2 !~ m/[a-e]/ && $fl1 !~ m/[a-e]/){
        @tmp1 = split('',"$fl1$fl2");
        @tmp1 = sort(@tmp1);
        $tmp =  join('',@tmp1);
        $tmp =~ s/(\w)\1/$1/g;
        $fl1 = $tmp;
}else{
        if( $fl1 eq ""){
               print "$wyr1\n";
         }else{
               print "$wyr1\/$fl1\n";
         }
         $wyr1 = $wyr2;
         $fl1  = $fl2;
}