![]() |
|
Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Optimise file line by line parsing, substitute SPLITby Tux (Canon) |
on Jun 03, 2013 at 14:13 UTC ( [id://1036764]=note: print w/replies, xml ) | Need Help?? |
If your data is easy to split on TAB's, perl's split is exceptionally fast. Building on BrowserUk's example - which is a good example - look at this test:
where vsespb is missing the point, is that when determining if a record is to be split or not, one still has to look at the record. That is exaclty what BrowserUk was pointing at. Looking at the first character of a record is a cheap operation, not needing split at all, but if you want to decide processing on the content of the 11th field, you have to split before you can decide. All of the above will start changing when the fields can be quoted and have (valid) TAB characters inside the field, or if fields are allowed to have embedded newlines or when the fields are (much) longer. Compare to e.g.:
Enjoy, Have FUN! H.Merijn
In Section
Seekers of Perl Wisdom
|
|