| [reply] [d/l] [select] |
You are right - I did code it correctly in the .pl, but not in the post here (just (mis-typed) it in from memory). re Text::CSV, that's what I did at first but having switched to an open and read to be able to debug my draft-code issues with clarity, there is no reason to switch back to Text::CSV given that the csv file used is predictable enough to remove first and last chars and then split /\"\,\s*\"/. You could argue that this is a "not invented here" approach, but I am even more loth to use CPAN sledegehammers to crack tiny little nuts where a few characters are all that are needed to avoid loading a module. Think:
performance! Some cases are less obvious whether to use the CPAN module, but this one seems clear enough, although I will move it to a utility module where it can be readily replaced with a use of Text::CSV if circumstances change.
| [reply] |
There is a speed compare page available. Your split will FAIL on one of the easiest pitfalls, used for the timing. This perfectly formatted CSV line will break any split pattern, and it does not even contain embedded newlines:
hello,","," ",world,"!"
If you need correct CSV parsing of purely strict CSV, and that excludes space after the separator, use a module like Text::CSV::Easy_XS, which allows no deviation from the standard. If you require speed in addition to robustness, options (like space after the separator) and a usable interface, use Text::CSV_XS. If XS is not an option, use any of the _PP variants.
The more data you have to parse, the happier a module will make you. It's loading time outweighs the headaches of finding possible breakages.
Enjoy, Have FUN! H.Merijn
| [reply] [d/l] [select] |
| [reply] |