|
|
| P is for Practical | |
| PerlMonks |
Re: selecting columns from a tab-separated-values fileby Kenosis (Deacon) |
| on Jan 21, 2013 at 23:27 UTC ( #1014521=note: print w/ replies, xml ) | Need Help?? |
|
Consider slicing a split to get only the elements you need, instead of splitting the entire line, as it benchmarks significantly faster:
Results:
Update: Have added choroba's trySplitSliceLimit() option to the benchmarking. Update II: Thanks to AnomalousMonk, have appended "\tFOO" x 42 to the original string to create a string with 50 tab-delimited fields. This effectively shows the speed increase using trySplitSliceLimit(). Update III: Changed splitting on ' ' to \t. Thanks CountZero.
In Section
Seekers of Perl Wisdom
|
|