Here is my two cents worth:

my %abbrev = ( G => 'Green', Y => 'Yellow', R => 'Red', C => 'Checkered', U => 'Unflagged', ); sub get_state { my ( $self, $contents ) = @_; $contents =~ tr/\r//d; my %session; for ( split /\n/, $contents ) { if ( /^ *\d+\+*\|/ ) { # Data record my @values = split /\|/, $_, -1; s/^ *// for @values; my %stats; @stats{ @{ $self->{ fields } } } = @values; # do some clean up / bring to common values $stats{ position } =~ tr/+//d; # sometimes there is a " ++" $stats{ best_speed } =~ tr/+//d; # sometimes there is a " ++" at end $stats{ driver } =~ s/ *\(R\)$//; # I don't care if rookie unless ( length $stats{ status } ) { # not all the serie +s track run, pit, etc $stats{ status } = 'Run' } $stats{ status } =~ s/In Pit/Pit/ig; $stats{ status } =~ s/Active/Run/; $stats{ status } =~ s/Pace_Laps/Pace/; # convert time from MM:SS to seconds $stats{ last_lap } = $self->time_to_dec( $stats{ last_lap +} ); $stats{ best_lap } = $self->time_to_dec( $stats{ best_lap +} ); $stats{ id } = $stats{ car }; #Logger->log( Dumper( %stats ) ); push @{ $session{ positions } }, \%stats; } elsif ( /^</ ) { # Header my ( $event, $flag, $msg ) = ( split /\|/, $_, -1 )[ 0, 5, + 16 ]; ( $session{ event } = $event ) =~ s/<!//; if ( length $flag ) { $session{ flag } = exists $abbrev{ $flag } ? $abbrev{ +$flag } : $flag; } $msg =~ s/^>?.* : //; $session{ control_message } = $msg if $msg !~ /^\S+ flag/i +; } else { #print "garbage: $_\n"; } } Logger->log( "series: |$session{series}| event: |$session{event}| +flag: |$session{flag}| time: |$session{time}|" ); return %session; }

In reply to Re: Idiomize This - Cleanup/Transform by jwkrahn
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.