in reply to splitting up data...

If it's an assignment, they might not want you to rely too much on a specific module.

It *sounds* like you want to do the following:

  1. Open a file and count how many lines it has
  2. Divide the number of lines by an integer (to find out how many lines to write to each of your output files)
  3. Output n lines to each file, basing the filename on the value of n

Here's some (untested) code to help you with the first 2 steps:

open(IN, $ARGV[0])||die "Cannot open $ARGV[0]:$!\n"; die "No number of lines\n" unless($ARGV[1] =~ /^\d+$/); my $lines = 0; $lines ++ while(<IN>); close IN; print "lines per output file = " . int($lines/$ARGV[1]) . "\n";
Tom Melly, tom@tomandlu.co.uk

Replies are listed 'Best First'.
Re^2: splitting up data...
by chinamox (Scribe) on Oct 22, 2006 at 01:56 UTC
    Thank you for the pointer, it was exactally what I was looking for!

    -mox