thanks ronald and bruce actually both your suggestions took exactly the same amount of time on a 40mb file. i have an additional question i forgot last time. i' d like to get the linenumber for the very last character of the large file before actually doing the seperating-procces - are there a special variable or a quick way to do this? thanks again allan > #!perl -w > my $file = "hit.txt"; > my $lines= 0; > open BIG, $file or die "Can't open $file: $!\n"; > open NEW, ">$lines.txt" or die "Can't open $lines.txt: $!\n"; > while (<BIG>) { > print NEW $_; > next if $. % 1000; > close NEW; > $lines = $.; > open NEW, ">$lines.txt" or die "Can't open $lines.txt: $!\n"; > } > > __END__ > #!perl > > use strict; > > my $in = shift @ARGV; # input file > my $out = $in; # output file base name > my $suf = '000'; # initial suffix to add to base name > > my $max = 1000; # max number of lines per output file > my $curr = 0; # number of lines read for current file > > open(IN, $in) # open input file > or die "Unable to open $in: $!\n"; > > open(OUT, '>' . $out . $suf++) # open first output file > or die "Unable to open $out: $!\n"; > > while (<IN>) { # read one line > if ($curr++ == $max) { # if at max > open(OUT, '>' . $out . $suf++) # open next output file > or die "Unable to open $out: $!\n"; > $curr = 1; # reset current > } > > print OUT $_; # print this line > } # while (<IN>) > > __END__ ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org