JayDog has asked for the wisdom of the Perl Monks concerning the following question:
my $chunksize = 500 * 1024; # 500Kb my $filenumber = 0; my $infile = "infile.dat"; my $outsize = 0; my $eof = 0; open INFILE, $infile; open OUTFILE, ">outfile_".$filenumber.".dat"; while(<INFILE>) { chomp; $outsize++; 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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Removing Large Invoices from a Data File
by BrowserUk (Patriarch) on Jun 01, 2007 at 22:49 UTC | |
|
Re: Removing Large Invoices from a Data File
by GrandFather (Saint) on Jun 01, 2007 at 22:48 UTC | |
|
Re: Removing Large Invoices from a Data File
by Limbic~Region (Chancellor) on Jun 02, 2007 at 03:30 UTC | |
|
Re: Removing Large Invoices from a Data File
by Util (Priest) on Jun 02, 2007 at 03:48 UTC |