2020-06-03 15:39:18 +03:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
#
|
|
|
|
# simple script for filling/clipping data to a certain size
|
|
|
|
# in number of lines
|
|
|
|
|
|
|
|
use strict;
|
2020-06-08 14:14:55 +03:00
|
|
|
use Getopt::Std;
|
|
|
|
|
|
|
|
use vars qw/$opt_m/;
|
|
|
|
|
|
|
|
getopts('m:');
|
2020-06-03 15:39:18 +03:00
|
|
|
|
|
|
|
my $size = shift(@ARGV);
|
|
|
|
my $file = shift(@ARGV);
|
|
|
|
|
|
|
|
my $count=0;
|
2020-06-08 14:14:55 +03:00
|
|
|
my $repeated=0;
|
2020-06-03 15:39:18 +03:00
|
|
|
while ($count < $size){
|
|
|
|
open F,"<$file" || die "cannot read from $file!\n";
|
|
|
|
while (<F>){
|
|
|
|
$count++;
|
|
|
|
print;
|
|
|
|
last if ($count >= $size);
|
|
|
|
}
|
2020-06-08 14:14:55 +03:00
|
|
|
close F;
|
|
|
|
$repeated++;
|
|
|
|
last if ($opt_m && $repeated > $opt_m);
|
2020-06-03 15:39:18 +03:00
|
|
|
}
|