Hello Johnny,

At 12:31 PM 11/4/2002 -0500, Johnny Hall wrote:
>I am trying to take a file of variable length on a daily basis and
>divide it up into 4 equal parts for processing on each file.  Does
>someone have an easy way to do this?  

Did not read your attachment since my mail processor removes attachments
from list e-mails (sorry, too much spam).

Below is a sample script which may lead you in the right direction.  If you
call it foo.pl, you can use it like so:
  # seq 1 100 | foo.pl
or like so:
  # foo.pl some.file.txt

Is this what you were looking for?  Feel free to modify to your needs.

Regards,
- Robert

-----

#!/usr/bin/perl -w
# (c) 2002 - Robert Citek
# released under the GPL (http://www.gnu.org/licenses/gpl.txt)

use strict;
use English;  # I prefer $NR over $.

my $num=4;
my @fh;

# create an array of filehandles
for (my $i=0; $i<$num ; $i++) {
  open($fh[$i], "> tmp.F$i") or die "$!\n";
}

# divide output lines into various files
while (my $line=<>) {
  my $foo=$fh[(($NR-1)%$num)];
  print $foo $line;
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to