Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by Anonymous Monk
on Feb 09, 2025 at 18:55 UTC ( [id://11163971]=note: print w/replies, xml ) Need Help??


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???

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11163971]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2025-05-22 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.