develooper Front page | perl.perl5.porters | Postings from May 2021

Re: Revisiting trim

Thread Previous | Thread Next
From:
Uri Guttman
Date:
May 26, 2021 21:50
Subject:
Re: Revisiting trim
Message ID:
0ec6abf9-ce7c-fbc5-dc0c-1fcd10b25d94@stemsystems.com
On 5/26/21 5:13 PM, Alberto Simões wrote:
>
> On Wednesday, May 26th, 2021 at 21:55, Uri Guttman 
> <uri@stemsystems.com> wrote:
>
>>
>> what about trimmed using context? in a void context it trims in 
>> place. in scalar (or non-void) it returns the trimmed string and 
>> leaves the input unchanged. only one new function and we use context 
>> everywhere so it is familiar.
>>
>>
> While I like the idea, we would need to make other methods to have 
> similar behavior:
>    - lc / uc / ucfirst
>    - chomp / chop
> and probably others.
>
>

chop/chomp already have return values so they can't be changed. the 
ls/uc ones could have void context to work.

another issue is that void context needs an lvalue as an argument so it 
can modify in place.
the pass results versions (in non-void context) can take any expression.

uri


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