[SP-pm] Capturar trechos de um arquivo de log

Daniel de Oliveira Mantovani daniel.oliveira.mantovani at gmail.com
Sun Mar 13 00:59:57 PST 2011


On 13 March 2011 05:37, Nelson Ferraz <nferraz em gmail.com> wrote:
> Solução rápida (e não testada):
>
> my (@buffer,$current_status);
> while (my $line = <>) {
>    push $line, $buffer;

Acredito que você quis dizer,
  push @buffer,$line;

:)

>
>    if ($line =~ /Status:\s*(\w+)/) {
>        $current_status = $1;
>    }
>
>    if ($line =~ /End/) {
>        if ($current_status eq 'ERROR') {
>            print join("\n", @buffer);
>        }
>
>        @buffer = ();
>    }
> }
> =begin disclaimer
>   Sao Paulo Perl Mongers: http://sao-paulo.pm.org/
>  SaoPaulo-pm mailing list: SaoPaulo-pm em pm.org
>  L<http://mail.pm.org/mailman/listinfo/saopaulo-pm>
> =end disclaimer
>



-- 
"If you’ve never written anything thoughtful, then you’ve never had
any difficult, important, or interesting thoughts. That’s the secret:
people who don’t write, are people who don’t think."


More information about the SaoPaulo-pm mailing list