MightyJayDog
Technical User
I have a large data file that I got some help from brigmar to split into smaller more manageable chunks (went from a 12.86 GB file to 500 MB - 1.6 GB chunks).
I now want to add to the PERL script and go back through those chunks and pull out any invoices within those smaller data files that are larger than 250 MB each and print them to their own files as well.
How do I go about doing that?
Here is what I am currently working with...
I now want to add to the PERL script and go back through those chunks and pull out any invoices within those smaller data files that are larger than 250 MB each and print them to their own files as well.
How do I go about doing that?
Here is what I am currently working with...
Code:
#!usr/bin/perl -w
my $chunksize = 500000000; # 500MB
my $filenumber = 0;
my $infile = "infile.dat";
my $outsize = 0;
my $eof = 0;
open INFILE, $infile;
open OUTFILE, ">outfile_".$filenumber.".dat";
while(<INFILE>)
{
chomp;
if( $outsize>$chunksize and /^.{67}11/ )
{
close OUTFILE;
$outsize = 0;
$filenumber++;
open (OUTFILE, ">outfile_".$filenumber.".dat") or die "Can't open outfile_".$filenumber.".dat";
}
print OUTFILE "$_\n";
$outsize += length;
}
close INFILE;