The problem is solved; thanks for your patience with my ill-formed question that turned out not to be the problem at all.
# split-unix.pl -- do split in perl
#
# usage:split [-num] file [outname]
use strict;
my $outfile = "x"; #default
my $limit = 1000;
my $readfile;
my $s1= "a";
if($ARGV[0] =~/^-?[0-9]+/){
$limit = 0- $ARGV[0];
shift @ARGV;
}
$readfile = $ARGV[0];
shift @ARGV;
if (defined $ARGV[0]){
$outfile = $ARGV[0];
}
$outfile.=$s1;
open (OUT, ">", $outfile) or die "$0: can't open $outfile $!";
open (IN, "<", $readfile) or die "$0: can't open $readfile $!";
print OUT $limit;
#=pod
while(<IN>){
if ($. > $limit ){
close OUT;
$outfile++;
open(OUT, ">", $outfile) or die "$0: can't open $outfile $!";
}
print OUT "$_";
}
#=cut
close OUT;
|