Last change
on this file since f712e16 was
57728c1,
checked in by Mateusz Hromada <ruanda@…>, 15 years ago
|
Move old files to _old dir.
|
-
Property mode set to
100755
|
File size:
1.1 KB
|
Rev | Line | |
---|
[f1563c0] | 1 | #!/usr/bin/perl |
---|
| 2 | |
---|
| 3 | # Usuwa zbêdne powtórzenia scie¿ek |
---|
| 4 | |
---|
| 5 | use locale; |
---|
| 6 | |
---|
| 7 | #if (@ARGV < 1) { |
---|
| 8 | # print "USAGE: remDup.pl num\n\tGdzie \"num\" jest ilo¶ci± powtórzeñ, które zostawiamy\n"; |
---|
| 9 | # exit(0); |
---|
| 10 | #} |
---|
| 11 | |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | #ilo¶æ powtórzeñ, które zostawiamy |
---|
| 15 | $max = 10; |
---|
| 16 | |
---|
| 17 | # przyjmujemy, ze na wej¶ciu znajduje siê plik posortowany, |
---|
| 18 | # po koñcówkach oraz po prawdopodobieñstwie |
---|
| 19 | |
---|
| 20 | $line = <>; |
---|
| 21 | |
---|
| 22 | while (($line !~ m/^$/) || ($line =~ m/^\n$/)) { |
---|
| 23 | |
---|
| 24 | $count = 0; |
---|
| 25 | |
---|
| 26 | while ($line =~ m/^\n$/) { |
---|
| 27 | $line = <>; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | $line =~ /^([^~]+)~.*/; |
---|
| 31 | $theEnd = $1; |
---|
| 32 | $end = $1; |
---|
| 33 | |
---|
| 34 | while (($end =~ m/$theEnd/) && ($count++ < $max)) { |
---|
| 35 | print $line; |
---|
| 36 | $line = <>; |
---|
| 37 | $line =~ /^([^~]+)~.*/; |
---|
| 38 | $end = $1; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | # tutaj mamy dwie mo¿liwo¶ci: |
---|
| 42 | # 1. wypisali¶my ju¿ max lini - musimy wywaliæ kolejne linie, które |
---|
| 43 | # zawieraj± koñcówkê theEnd, |
---|
| 44 | # 2. pasuj±cych lini by³o mniej ni¿ max, wtedy nic nie musimy robiæ |
---|
| 45 | # - w zmiennej line znajduje siê kolejna linia... |
---|
| 46 | |
---|
| 47 | if ($count == $max + 1) { |
---|
| 48 | while ($oldEnd =~ m/$theEnd/) { |
---|
| 49 | $line = <>; |
---|
| 50 | $line =~ /^([^~]+)~.*/; |
---|
| 51 | $oldEnd = $1; |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.