new-words

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/part.pl	Mon May 17 12:14:44 2010 +0300
     1.3 @@ -0,0 +1,39 @@
     1.4 +#!/usr/bin/perl
     1.5 +
     1.6 +my @lines=<STDIN>;
     1.7 +my $lines=$#lines;
     1.8 +my $interval=$ARGV[0];
     1.9 +my ($start,$stop,$total);
    1.10 +if ($interval =~ m@(.*)/(.*)@) {
    1.11 +    $start = $1;
    1.12 +    $total = $2;
    1.13 +}
    1.14 +else {
    1.15 +    $start=$interval;
    1.16 +    $total=0;
    1.17 +}
    1.18 +if ($start =~ m@(.*)-(.*)@) {
    1.19 +    $start = $1;
    1.20 +    $stop = $2;
    1.21 +}
    1.22 +if ($start =~ m@(.*)\+(.*)@) {
    1.23 +    $start = $1;
    1.24 +    #if ($2 =~ /%$/) {
    1.25 +    #}
    1.26 +    #else {
    1.27 +    $stop = $start+$2;
    1.28 +    #}
    1.29 +}
    1.30 +#print "start = $start\n";
    1.31 +#print "stop = $stop\n";
    1.32 +#print "total = $total\n";
    1.33 +
    1.34 +$start=int($lines/$total*$start);
    1.35 +$stop=int($lines/$total*$stop);
    1.36 +
    1.37 +#print "start = $start\n";
    1.38 +#print "stop = $stop\n";
    1.39 +#print "total = $total\n";
    1.40 +for($i=$start;$i<$stop;$i++){
    1.41 +    print $lines[$i];
    1.42 +}