# split-unix.pl -- do split in perl # # usage:split [-num] file [outname] my $outfile = "x"; #default my $limit = 1000; my $readfile; my $s1= "a"; if (scalar(@ARGV) > 3){ usage; } if($ARGV[0] =~/^[0-9]+/){ $limit = -$ARGV[0]; shift @ARGV; } $readfile = $ARGV[0]; shift @ARGV; if (defined $ARGV[0]){ $outfile = $ARG[0]; } $outfile.=$s1; open ($write, ">", $outfile) or die "$0: can't open $outfile $!"; open ($fh, "<", $readfile) or die "$0: can't open $readfile $!"; while(<>){ if ($. < $limit){ print; } else{ $outfile++; $write=""; # I think this answers my question open ($write, ">", $outfile) or die "$0: can't open $outfile $!"; } }