Shared publicly  - 
Why isn't there a straight forward answer to trimming a string in PERL? regex speed tests comparing two regexs vs a single regex...i just want a simple trim function that I can count on being there, without defining one myself. CPAN is fine, but what is that module. trim in the core?
TRIM in Perl? by peacemaker1820 (Pilgrim). Log in; Create a new user; The Monastery Gates; Super Search; Seekers of Perl Wisdom; Meditations; PerlMonks Discussion; Obfuscation; Reviews; Cool Uses For ...
Lars Dɪᴇᴄᴋᴏᴡ's profile photoDave Horner's profile photoCurtis Poe's profile photoJohn Douglas Porter's profile photo
.strip() in python. PERL, we get two regexs as defacto, with a single concise regex questioned as to speed. timtowtdi.
Adding trim to the language means defining a keyword and that conflicts with code that already contains e.g. a trim subroutine, IOW it's not backward-compatible and that goes against P5P's conservative stance. You really want perl5i, where extending the language becomes as simple as adding just another method, and trim is already included. <> Using a module is always an option, see Sam Graham's comparison. <>
Thank you Lars, I had not seen String::Strip or the perl5i trim!

I would prefer using a perl5i, but prefer the portability of something like String::Strip, but then you see two open bugs, one of which is looking for a maintainer/more test/modernization.

It surprises me the value of having something like strip() defined within the language... or even within the 3rd party module librarys (CPAN). Why String::Strip didn't exist until 2000, and today has two open bugs doesn't make sense to me. It is so common a task, and most people just bite the bullet and inline the double regex statements or define their own method to hide the double regex.

looks like .trim is coming in perl perl5i is portable in a sense....

Thanks again Lars.
+Dave Horner .trim() is also built-in to Perl6. I wrote the original implementation in PASM, but I suspect it's been rewritten by now as my implementation was a couple of years ago.
Right, maybe you didn't see my full expanded comment:
looks like .trim is coming in perl perl5i is portable in a sense....
portable, but forcing the developer to move to perl6/perl5i to get it. (which is best I guess)
CPAN module route seems like it would be an easy and portable way. But you feel silly to import a module just for strip...not to mention outstanding 64bit bug and no maintainer.

going to perl6 isn't a walk in the park conversion, and I'm not familiar with perl5i, but it looks like a nice alternative. Systems are out there with 5.x and they need to continue working. I wonder how perl5i does on all the platforms aix/sun/etc with older 5.x. perl5i and .trim() may be what I have been searching for.

Thanks for the note Curtis, I haven't tried a bit of PASM myself yet, maybe some day.
Being a Perl programmer has helped me get plenty of trim. What's your problem?
Yes, being a Perl programmer has caused many a developer to implement their choice of a trim implementation, each in their own code. Did I not expound the point enough?
+Dave Horner You're right, I didn't see your full comment. Now I'm curious to know if my code still survives. I'll have to check :)
my comment above was meant to be humorous. I'm sorry if I offended anyone.
Add a comment...