develooper Front page | perl.perl5.porters | Postings from February 2022

Re: trim vs trimmed revisited

Thread Previous | Thread Next
From:
David Nicol
Date:
February 25, 2022 07:24
Subject:
Re: trim vs trimmed revisited
Message ID:
CAFwScO92bpf2TczN_bXDGqWdME8CzwAsftj1jin=84kAqPsbjg@mail.gmail.com
IMO trim should operate in place in void context and return the substring
in nonvoid context. Optimizing


>> $string = trim($string);
>

Into

        ; trim($string);

is clearer but unnecessary.

      $string =~ s/\s*(.*?)\s*$/$1/;

>

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