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

Re: Revisiting trim

Thread Previous | Thread Next
Uri Guttman
May 26, 2021 21:50
Re: Revisiting trim
Message ID:
On 5/26/21 5:13 PM, Alberto Simões wrote:
> On Wednesday, May 26th, 2021 at 21:55, Uri Guttman 
> <> 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.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About