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

Nelson Ferraz nferraz at gmail.com
Sun Mar 13 00:37:22 PST 2011


Solução rápida (e não testada):

my (@buffer,$current_status);
while (my $line = <>) {
    push $line, $buffer;

    if ($line =~ /Status:\s*(\w+)/) {
        $current_status = $1;
    }

    if ($line =~ /End/) {
        if ($current_status eq 'ERROR') {
            print join("\n", @buffer);
        }

        @buffer = ();
    }
}


More information about the SaoPaulo-pm mailing list