John W. Krahn wrote:
>
> Instead of using eval inside of a loop it is a
> lot faster if you eval the whole loop.
>
> # slow
> my $expr = '/$regex/';
> while ( <FILE> ) {
>     if ( eval $expr ) {
>         do { something() };
>         }
>     }
>
> # a lot faster
> my $loop = <<'LOOP';
> while ( <FILE> ) {
>     if ( /$regex/ ) {
>         do { something() };
>         }
>     }
> LOOP
> eval $loop;

Nice one John. Thanks.

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to