in reply to RE: Re: still confused with CGI and carriage returns carriage returns
in thread still confused with CGI and carriage returns carriage returns
The moral of the story: Use tr/// where you can.use Benchmark; $str = "\n#\n#\nSTUFF\n#\n#\n"; timethese(1000000, { 's' => sub { $a = $str; $a=~s/\n/ /g; }, 'tr' => sub { $a = $str; $a=~tr/\n/ /; } }); RESULTS: Benchmark: timing 1000000 iterations of s, tr... s: 11 wallclock secs (11.22 usr + 0.00 sys = 11.22 CPU) tr: 3 wallclock secs ( 3.61 usr + 0.00 sys = 3.61 CPU)
|
|---|