Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
This is the first chunk. // This is the second chunk. // This is the third chunk. //
Would it be efficient to use an "if" clause, like:$/="//\n"; $count_records=0; open OUT1, ">>0_999"; open OUT2, ">>1000_2000"; open OUT3, ">>2001_3000"; while(<>) { $record=$_; $count_records++; }
or is there a quicker way to do it?"If $count_records<=999 --> print OUT1 $record"<br> "If 1000<=$count_records<=1999 --> print OUT2 $record"<br> "If 2000<=$count_records<=2999 --> print OUT3 $record"<br>
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: split file into smaller chunks
by davorg (Chancellor) on Jul 17, 2009 at 08:57 UTC | |
Re: split file into smaller chunks
by moritz (Cardinal) on Jul 17, 2009 at 08:54 UTC | |
Re: split file into smaller chunks
by ELISHEVA (Prior) on Jul 17, 2009 at 09:03 UTC | |
by Anonymous Monk on Jul 17, 2009 at 21:43 UTC | |
by ELISHEVA (Prior) on Jul 18, 2009 at 18:38 UTC | |
Re: split file into smaller chunks
by Marshall (Canon) on Jul 18, 2009 at 07:10 UTC |