M
Max
I can't seem to figure out what I'm doing wrong, or maybe I'm just rushing
as I need to split a 15000 line file into chunks.
This script is supposed to work by giving the line number you want to start
at and the line number you want to stop at. It should copy all lines in
between the start and stop number to a file called $file-split. But it
doesn't seem to work. If someone has a few minutes, can you tell me what
I'm doing wrong.
Thanks in advance.
#!/usr/bin/perl
$file = $ARGV[0];
$start = $ARGV[1];
$stop = $ARGV[2];
print "$start\n";
print "$stop\n";
$cnt = 0;
open (IN, "$file");
open (OUT, "> $file-split");
while (<IN>) {
chomp;
$cnt++;
next if ($cnt lt $start);
last if ($cnt gt $stop);
print OUT "$_\n";
}
close (IN);
close (OUT);
as I need to split a 15000 line file into chunks.
This script is supposed to work by giving the line number you want to start
at and the line number you want to stop at. It should copy all lines in
between the start and stop number to a file called $file-split. But it
doesn't seem to work. If someone has a few minutes, can you tell me what
I'm doing wrong.
Thanks in advance.
#!/usr/bin/perl
$file = $ARGV[0];
$start = $ARGV[1];
$stop = $ARGV[2];
print "$start\n";
print "$stop\n";
$cnt = 0;
open (IN, "$file");
open (OUT, "> $file-split");
while (<IN>) {
chomp;
$cnt++;
next if ($cnt lt $start);
last if ($cnt gt $stop);
print OUT "$_\n";
}
close (IN);
close (OUT);