You didn't provide any example data for testing, so I can't guarantee that the following actually works. It does compile though.

my %abbreviations = ( G => 'Green', Y => 'Yellow', R => 'Red', C => 'Checkered', U => 'Unflagged', ); my @cleanups = ( [ position => qr{\+}, undef, 'g' ], # sometimes there is a "+" [ driver => qr{\s*\(R\)$} ], # I don't care if rookie [ best_speed => qr{\+}, undef, 'g' ], # sometimes there is a "+" a +t end [ status => qr{\A\z}, 'Run' ], # not all the series track run, + pit, etc [ status => qr{In Pit}i, 'Pit' ], [ status => qr{Active}i, 'Run' ], [ status => qr{Pace_Laps}i, 'Pace' ], ); sub get_state { my ($self, $contents) = @_; $contents =~ s/\r//g; my %session = (); foreach (split /\n/, $contents) { if (/^ \s* \d+ [+]* [|] /x) { # Data record my %stats; @stats{@{$self->{fields}}} = map { s/^\s*// } split /\|/; foreach my $cleanup (@cleanups) { my ($key, $match, $replace, $global) = @$cleanup; $global ? ( $stats{$key} =~ s/$match/$replace/g ) : ( $stats{$key} =~ s/$match/$replace/ ) } # convert time from MM:SS to seconds $stats{$_} = $self->time_to_dec($stats{$_}) for qw(last_la +p best_lap); $stats{id} = $stats{car}; #Logger->log(Dumper(%stats)); push @{$session{positions}}, \%stats; } elsif (/^</) { # Header my @values = split(/\|/); my $abbrv = $values[5]; $session{flag} = $abbreviations{$abbrv} // $abbrv unless $abbrv eq ''; my $msg = $values[16]; $msg =~ s/^>//; $msg =~ s/^.* : //; $session{control_message} = $msg unless $msg =~ /^\S+ flag +/i; $session{event} = $values[0]; $session{event} =~ s/\<\!(.*)/$1/; } else { #print "garbage: $_\n"; } } Logger->log("series: |$session{series}| event: |$session{event}| f +lag: |$session{flag}| time: |$session{time}|"); return %session; }
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

In reply to Re: Idiomize This - Cleanup/Transform by tobyink
in thread Idiomize This - Cleanup/Transform by johnr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.