develooper Front page | perl.perl5.porters | Postings from July 2020

Re: Request review for adding a text trim() function to core

Thread Previous | Thread Next
From:
Alexander Hartmaier
Date:
July 21, 2020 19:47
Subject:
Re: Request review for adding a text trim() function to core
Message ID:
CAB49QrYLo6FL=3xQHUkiQRWpH-MS5Vv00dVkj3LbxEE+3gqjMA@mail.gmail.com
On Tue, Jul 21, 2020 at 8:35 PM Eric Brine <ikegami@adaelis.com> wrote:

> Having a function to trim both ends but not one to trim trailing
> whitespace is really weird to me. Virtually every program I write needs the
> latter (though I usually settle for chomp).
>
> On Tue, Jul 21, 2020 at 1:59 PM Scott Baker <scott@perturb.org> wrote:
>
>> It's been a personal pet peeve of mine that Perl has never had a *trim()*
>> function in core. After discussion
>> <https://github.com/Perl/perl5/issues/17952> with Grinnz, Leonerd, and
>> others we decided to move forward with seeing what it would take to add it
>> to core. I wrote documentation and tests, and LeoNerd wrote the actual
>> implementation. Now I'm here soliciting feedback on this feature before I
>> submit a formal PR.
>>
>> You can checkout my branch here:
>> https://github.com/scottchiefbaker/perl5/tree/trim
>>
>> Once it's built the easier way to test it is: ./perl -Ilib -E 'say
>> CORE::trim("   Hello world!    ");'
>>
>> You will get an experimental warning, but the function should work and
>> remove the whitespace.
>>
>> - Scottchiefbaker
>>
>
I've added some comments on Github but overall I'd love to see such a
function!
Control over what characters should be trimmed would be awesome and default
to what it currently does.
That way you could also use it to trim brackets for example.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About