> someone may have an answer. Or it would be interesting to hear if
> others do
> what I do, or if I am paying the price in time for cleaning?
Just for curiosity's sake, I timed the trimming operation on my laptop (600
MHz Pentium III, Windows 2000) using the benchmark module. Running the trim
operation on a pretty long string (400 whitespace characters at each end of
the string) and doing it 100,000 times only took 4.3 seconds of time. Unless
your CGI script is trimming hundreds of thousands of variables, the overhead
needed to perform this check is negligible.
As a related note, I also timed how long it would take to perform the trim
using a single regular expression, and found that doing
$myvar =~ s/^\s*|\s*$//;
took nearly twice as long as doing
$myvar =~ s/^\s*//; $myvar =~ s/\s*$//;
Results from the Benchmark module for both approaches on my box:
C:\>perl test.pl
Benchmark: timing 100000 iterations of OneRegexp, TwoRegexps...
OneRegexp: 7 wallclock secs ( 6.41 usr + 0.00 sys = 6.41 CPU) @
15603.06/s (
n=100000)
TwoRegexps: 4 wallclock secs ( 4.25 usr + 0.00 sys = 4.25 CPU) @
23557.13/s (
n=100000)
Tamara
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web