On 3/26/21 8:05 PM, Christian Walde wrote: > On Sat, 27 Mar 2021 02:03:51 +0100, B. Estrade <brett@cpanel.net> wrote: > >> >> >> On 3/26/21 7:58 PM, Christian Walde wrote: >>> On Sat, 27 Mar 2021 01:53:54 +0100, B. Estrade <brett@cpanel.net> wrote: >>> >>>> At the end of the day, it seems to me that the real motivation for >>>> this is to eliminate this idiom: >>>> chomp($foo); >>>> $foo =~ s/^ *//g; # or however YOU do it >>> >>> Nope, the motivation is to replace this: >>> >>> $a =~ s/^\s+//; $a =~ s/\s+$//; Apologies for another post, but rather than as, "well what single regex would replace this" it was easy enough for me to just figure it out: perl -e '$x=" foo "; $x =~ s/^\s*([^\s]*)\s*$/$1/; print $x' My intent is not to hijack this by asking how many ways there are to DWIM; but I am happy that it took me less than 10 minutes to figure it out - at least for my trivial string, " foo ". Cheers, Brett >>> >>> Which is like 1600+ times on cpan. >>> https://grep.metacpan.org/search?q=%5C%5E%5C%5Cs%5C%2B%5B%5E%5C0%5D%2B%5C%5Cs%5C%2B%5C%24%7C%5C%5Cs%5C%2B%5C%24%5B%5E%5C0%5D%2B%5C%5E%5C%5Cs%5C%2B&qd=&qft= >>> >> >> Okay; well in this case my personal preference is to see a trim that >> misbehaves as chomp does; even if it trims both sides. That boils down >> to affecting the value in-place - or rather not introducing another >> special case of explicit string manipulation that behaves differently >> than one the one provided; the rest remaining on that crusty old regex >> thing. > > Fwiw, the best implementation, as i mentioned elsewhere and as was > mentioned copiously in the github issue is: > > Make both. > > Both of them have important and valid applications. > > Also having trim and tromp would be super funny. > >>> That said, i also recommend asking the author, Scott, for his >>> motivation. :) >> >> Okay, Scott? Inquiring minds would like to know :) > > :D > >Thread Previous | Thread Next