new-words
annotate part.pl @ 24:1318aa5898ee
minifix:getopts
author | Igor Chubin <igor@chub.in> |
---|---|
date | Mon May 17 12:14:44 2010 +0300 (2010-05-17) |
parents | |
children |
rev | line source |
---|---|
igor@22 | 1 #!/usr/bin/perl |
igor@22 | 2 |
igor@22 | 3 my @lines=<STDIN>; |
igor@22 | 4 my $lines=$#lines; |
igor@22 | 5 my $interval=$ARGV[0]; |
igor@22 | 6 my ($start,$stop,$total); |
igor@22 | 7 if ($interval =~ m@(.*)/(.*)@) { |
igor@22 | 8 $start = $1; |
igor@22 | 9 $total = $2; |
igor@22 | 10 } |
igor@22 | 11 else { |
igor@22 | 12 $start=$interval; |
igor@22 | 13 $total=0; |
igor@22 | 14 } |
igor@22 | 15 if ($start =~ m@(.*)-(.*)@) { |
igor@22 | 16 $start = $1; |
igor@22 | 17 $stop = $2; |
igor@22 | 18 } |
igor@22 | 19 if ($start =~ m@(.*)\+(.*)@) { |
igor@22 | 20 $start = $1; |
igor@22 | 21 #if ($2 =~ /%$/) { |
igor@22 | 22 #} |
igor@22 | 23 #else { |
igor@22 | 24 $stop = $start+$2; |
igor@22 | 25 #} |
igor@22 | 26 } |
igor@22 | 27 #print "start = $start\n"; |
igor@22 | 28 #print "stop = $stop\n"; |
igor@22 | 29 #print "total = $total\n"; |
igor@22 | 30 |
igor@22 | 31 $start=int($lines/$total*$start); |
igor@22 | 32 $stop=int($lines/$total*$stop); |
igor@22 | 33 |
igor@22 | 34 #print "start = $start\n"; |
igor@22 | 35 #print "stop = $stop\n"; |
igor@22 | 36 #print "total = $total\n"; |
igor@22 | 37 for($i=$start;$i<$stop;$i++){ |
igor@22 | 38 print $lines[$i]; |
igor@22 | 39 } |