Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $cat error_log
- <parameter>:test_tot_count
- <result>:1
- <stderr>:Expected "test_tot_count=2" and the actual value is 3
- test_tot_count = 3
- <parameter>:test_one_count
- <result>:0
- <stderr>:Expected "test_one_count=2" and the actual value is 0
- test_one_count = 0
- <parameter>:test_two_count
- <result>:4
- <stderr>:Expected "test_two_count=2" and the actual value is 4
- test_two_count = 4
- ...
- my $err_msg = "";
- while (<ERR_LOG>)
- {
- if (/<parameter>:/)
- {
- s/<parameter>://;
- push @parameter, $_;
- }
- elsif (/<result>:/)
- {
- s/<result>://;
- push @result, $_;
- }
- elsif (/<stderr>:/)
- {
- if (length($err_msg) > 0)
- {
- push @stderr, $err_msg;
- }
- s/<stderr>://;
- $err_msg = $_;
- }
- else
- {
- $err_msg .= $_;
- }
- }
- if (length($err_msg) > 0)
- {
- push @stderr, $err_msg;
- }
- use 5.010;
- while (<ERR_LOG>) {
- chomp;
- given ($_) {
- when ( m{^<parameter>: (.*)}x ) { push @parameter, $1 }
- when ( m{^<result>: (.*)}x ) { push @result, $1 }
- when ( m{^<stderr>: (.*)}x ) { push @stderr, $1 }
- default { $stderr[-1] .= "n$_" }
- }
- }
- use 5.010;
- my @records;
- my $prev_key;
- while (<ERR_LOG>) {
- chomp;
- given ($_) {
- when ( m{^<parameter> }x ) { push(@records, {}); continue; }
- when ( m{^<(w+)>: (.*)}x ) { $records[-1]{$1} = $2; $prev_key = $1; }
- default { $records[-1]{$prev_key} .= "n$_"; }
- }
- }
- (
- {
- parameter => 'test_one_count',
- result => 0,
- stderr => qq{Expected "test_one_count=2" and the actual value is 0ntest_one_count=0},
- },
- {
- parameter => 'test_two_count',
- result => 4,
- stderr => qq{Expected "test_two_count=2" and the actual value is 4ntest_two_count=4},
- }
- )
- my( $err_msg , %data );
- while (<ERR_LOG>) {
- if(( my $key ) = $_ =~ s/^<(parameter|result|stderr)>:// ) {
- if( $key eq 'stderr' ) {
- push @{ $data{$key} } , $err_msg if $err_msg;
- $err_msg = $_;
- }
- else { push @{ $data{$key} } , $_ }
- }
- else { $err_msg .= $_ }
- }
- # grab the last err_msg out of the hopper
- push @{ $data{stderr} } , $err_msg;
- if (/^<parameter>:/)
- if (/^<parameter>:(.*)/s)
- {
- push @parameter, $1;
- }
Add Comment
Please, Sign In to add comment