On Aug 10, Jeff 'japhy/Marillion' Pinyan said:
>On Aug 10, Michel Lambert said:
>
>>Fun with Perl's Regexes, to be more precise. They're a lot more fun than
>>regular regexes. Here's a little quiz I made up while falling asleep last
>>night.
>
>Mike, I'd call you sick, but I'd hate to think what adjective that would
>leave for me. ;)
>
>>1) What's the fastest way to strip trailing whitespace ( as defined by
>>/\s/ ) from a decent-sized string? Decent-sized means this email, or 100 of
>>these emails concatenated together.
>
>I'm standing behind my sexeger approach:
>
> $_ = reverse;
> s/^\s+//;
> $_ = reverse;
Unless (but this is important) the string is so heinously large that it'd
be smarter to do
1 while s/\s\z//;
(Yes, that looks evil, but it really works well.)
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **