http://qs1969.pair.com?node_id=79809


in reply to Removing Trailing Whitespace: Multiple ways.

Hey, good idea. The unpack solution assumes the length of the string is 8. It'll get a bit slower if it's generalized.

Update: Strike that. unpack "A*" runs faster than unpack "A8" on my machine. Anyone have an idea why that might be?

Benchmark: timing 1000000 iterations of unpack*, unpack8... unpack*: 7 wallclock secs ( 6.65 usr + 0.00 sys = 6.65 CPU) unpack8: 8 wallclock secs ( 7.40 usr + 0.00 sys = 7.40 CPU)