in reply to Re^2: Do I have to trick Split?
in thread Do I have to trick Split?
I have this problem a lot, and I've always written around it since I didn't know you could specify a negative limit and get all the trailing empties.
Pretty much the defining characteristic of Perl -- the real Perl that is; not a bastardised, pseudo-sanitised subset, nor an orthoganised, pseudo-java superset that the "modern" crowd would try to sell you on -- is that the built-ins are very well designed to deal with all the variations that you will ever need.
Many languages now have a split in their libraries, but none of them cater to all the common variations and edge cases the way Perl's does.
It was when early in my use of Perl: I repeatedly found myself needing to do something that I knew was going to be awkward and messy to deal with, only to find that Perl's designer(s) had been there before me, recognised the need and catered for it; that caused me to pin the Perl documentation in my browser for quick reference.
It's still there 13 years later. I don't have to look so often as I once did; but I am still discovering the purpose of stuff that I've read many times, but took no notice of because I didn't need it at that time, but that has been sitting there dormant just waiting for my need.
And it is that that brings me back to Perl time and time again. I'm currently trailing yet another new language -- this time Julia -- to replace my reliance on Perl. It is very cool language that acts exactly as a RELP-able, interpreted language; that when stressed, JITs into a near-C speed demon. But I recently spent a week trying to code something from scratch in Julia; that when I got frustrated took me 37 minutes from start to finish in Perl.
Even with the working Perl example and a 2/3rds complete Julia version it took 3 more days to get the Julia version working because of the need to manually code all the special cases that Perl takes care of for me. The result ran 13x faster, which in the long run of process that will run for months, is a huge saving and well worth the effort; but it will still be a long time before I give up Perl 5.
|
|---|