From: "Denham Eva" <[EMAIL PROTECTED]>
> Are you just trying to report the ORA-XXX errors in reverse order? If
> so, something like this should work:
> 
>     my @errs;
>     while (<SITELOG>) {
>         push @errs, $_ if /ORA-/;
>     }
>     print reverse @errs;

I wanted to ask why do you push the lines at the end and then reverse 
the array?

     my @errs;
     while (<SITELOG>) {
         unshift @errs, $_ if /ORA-/;
     }
     print @errs;

But Benchmark says your way is actually quicker :-)

#!perl
use Benchmark;

sub pushReverse {
        my @arr;
        for (1..10000) {
                push @arr, $_;
        }
        my @b = reverse @arr;
}

sub withUnshift {
        my @arr;
        for (1..10000) {
                unshift @arr, $_;
        }
        my @b = @arr;
}

timethese 10000, {
        pushReverse => \&pushReverse,
        withUnshift => \&withUnshift,
}
__END__
Benchmark: timing 10000 iterations of pushReverse, withUnshift...
pushReverse: 80 wallclock secs (78.39 usr +  0.05 sys = 78.44 CPU) 
        @ 127.49/s (n=10000)
withUnshift: 85 wallclock secs (83.84 usr +  0.09 sys = 83.94 CPU) 
        @ 119.14/s (n=10000)

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
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