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

Blabos de Blebe blabos at gmail.com
Sun Mar 13 08:34:58 PDT 2011


Uma máquina de estados não resolveria?

On Sun, Mar 13, 2011 at 5:59 AM, Daniel de Oliveira Mantovani
<daniel.oliveira.mantovani em gmail.com> wrote:
> 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."
> =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
>


More information about the SaoPaulo-pm mailing list