This is no surprise, regexp is a relatively heavy function, a lot of dirty
work behind the scene.

On Thu, Apr 16, 2009 at 2:13 PM, John W. Krahn <jwkr...@shaw.ca> wrote:

> Emen Zhao wrote:
>
>> This is off topic. But I'm just curious about why "4096" is picked here.
>> Is
>> there any particular reason behind it? I guess you can even calc the lines
>> like this -
>> perl -0777 -wne 'print scalar ($_=~s/\n//g)' filename
>>
>
> Except that it's slower than using tr///:
>
> $ time perl -ln0777e'print s/\n//g' < /usr/share/dict/words
> 98569
>
> real    0m0.160s
> user    0m0.092s
> sys     0m0.016s
> $ time perl -ln0777e'print tr/\n//' < /usr/share/dict/words
> 98569
>
> real    0m0.041s
> user    0m0.012s
> sys     0m0.012s
>
>
>
> John
> --
> Those people who think they know everything are a great
> annoyance to those of us who do.        -- Isaac Asimov
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to