I now want to add to the PERL script and go back through those more manageable 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...
Expand|Select|Wrap|Line Numbers
- #!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;