in reply to Any caveats in using unpack to right-trim? Why isn't it advertised more?

This was even faster than unpack:
chomp => sub { my @ret = @a; local $/ = ' '; 1 while chomp @ret; local $/ = "\n"; 1 while chomp @ret; \@ret; },
  • Comment on Re: Any caveats in using unpack to right-trim? Why isn't it advertised more?
  • Download Code

Replies are listed 'Best First'.
Re^2: Any caveats in using unpack to right-trim? Why isn't it advertised more?
by ikegami (Patriarch) on Feb 09, 2025 at 19:12 UTC

    Not nearly equivalent. \s matches much more than two characters. And this doesn't even handle the two characters it attempts to handle properly, since it doesn't trim <SP><LF><SP><LF>.

    But it does show that an XS solution that starts at the tail and works in-place would be fastest.

    This brings up my earlier comment, why doesn't builtin offer this???