On Sep 29, Hanson, Rob said:
>I ran some benchmarks.
>
>The two-liner outperformed the one-liners by a 10 to 1 ratio. Code and
>results below.
>
>Benchmark: timing 10 iterations of OneLine, OneLine2, TwoLines...
> OneLine: 41 wallclock secs (39.30 usr + 0.00 sys = 39.30 CPU) @ 2544.79/s
>
This is the correct reply.
That's some good stuff.
can you run a benchmark against these, contributed by others on this list,
as well?
$username =~ s/^\s*(.*?)\s*$/$1/;
s/^\s+//, s/\s+$// $username;
thanks,
-rkl
> I ran some benchmarks.
>
> The two-liner outperformed the one-liners by a 10 to
That's some good stuff.
can you run a benchmark against these, contributed by others on this list,
as well?
$username =~ s/^\s*(.*?)\s*$/$1/;
$username =~ s/^\s*(.*?)\s*$/$1/;
thanks,
-rkl
> I ran some benchmarks.
>
> The two-liner outperformed the one-liners by a 10 to 1 ratio. Code and
> res
this looks convenience
thanks,
-rkl
> [EMAIL PROTECTED] wrote:
>> Is there a func or a onliner for removing blanks from both ends?
>>
>> I'm using these:
>>
>> $username =~ s/^\s+//;
>> $username =~ s/\s+$//;
>>
>> There got to be one out there!
>
> Doing it in two steps is the way to go. Don't t
[EMAIL PROTECTED] wrote:
> Is there a func or a onliner for removing blanks from both ends?
>
> I'm using these:
>
> $username =~ s/^\s+//;
> $username =~ s/\s+$//;
>
> There got to be one out there!
Doing it in two steps is the way to go. Don't try to make one regex out of
it.
I usually write it
I ran some benchmarks.
The two-liner outperformed the one-liners by a 10 to 1 ratio. Code and
results below.
Benchmark: timing 10 iterations of OneLine, OneLine2, TwoLines...
OneLine: 41 wallclock secs (39.30 usr + 0.00 sys = 39.30 CPU) @ 2544.79/s
OneLine2: 34 wallclock secs (32.58 us
On Monday, September 29, 2003, at 07:04 PM, [EMAIL PROTECTED] wrote:
Is there a func or a onliner for removing blanks from both ends?
I'm using these:
$username =~ s/^\s+//;
$username =~ s/\s+$//;
We could combine those:
$username =~ s/^\s*(.*?)\s*$/$1/;
Hope that helps.
James
--
To unsubsc
That is what you want to use.
You could do it in a single regex:
## NOT RECOMMENDED - SEE NOTE BELOW ##
$username =~ s/^\s+|\s+$//g;
The downside is that this is not efficient and actually takes Perl longer to
perform the operation. If you want to know why you need to know a little
about how Per