Second NetWallah's comment re paid consulting (despite the contrarian act of providing of a solution).

Compare the split at line 19 of the previous with what you've done (again!).

And, to gild the lily, here's a variant on what the previous answer provided, done in a very cumbersome manner, in the hope it offers some additional insight into how the regex in split (and regexen generally) actually work:

my $data ="2008-Jan-01 00:00:00 UTC (GMT +0000) - Toll: channel = seve +n, ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx, tids = 123456789"; print "\n---->Variation 1 (Cumbersome coding to be explicit)\n\n"; # split just once, on " - " (space hyphen space) for the data given my ($datetime, $therest) = split /\s-\s/, $data; my ($toss1away,$channel,$therest2) = split /=\s(.*?),(.*)/, $therest; # capture anything between "= " and the next comma my ($toss2away,$ref,$tids_uncleaned) = split /=\s(.*?),/, $therest2; my ($toss3away,$tids) = split /=\s(.*)/, $tids_uncleaned; print "DT: " . $datetime . "\nChannel: " . $channel . "\nref: " . $ref + . "\ntids: " . $tids . "\n"; print "\n---->Variation 2 (Merely splits the data withOUT removing unn +eeded descriptors)\n\n"; my ($datetime,$channel,$ref,$tids) = split /\s-\s|,\s/, $data; # spl +it on , print "DT: " . $datetime . "\nChannel: " . $channel . "\nref: " . $ref + . "\ntids: " . $tids . "\n"; print "\n---->Variation 3 (Provides a header, removes descriptors from + data.\n\tCould easily be revised to push each set of multi-line data + to an AoA.)\n\n"; my $header=<<HEADER; DATETIME\t\t\t\tChannel\tRef\t\t\t\ttids ====================================================================== +======================== HEADER print $header; # now, get rid of "Toll: channel = " (so output is just "seven"), etc my ($throwaway,$cleanchannel) = split /\s=\s(.*)/, $channel; ($throwaway,my $cleanref) = split /\s=\s(.*)/, $ref; ($throwaway,my $cleantids) = split /\s=\s(.*)/, $tids; print "$datetime\t$cleanchannel\t$cleanref\t$cleantids\n";

OUTPUT

perl 675658-2.pl ---->Variation 1 (Cumbersome coding to be explicit) DT: 2008-Jan-01 00:00:00 UTC (GMT +0000) Channel: seven ref: xxx.xxxxxx.xxx.xxxxx.xxxxxxx tids: 123456789 ---->Variation 2 (Merely splits the data withOUT removing unneeded des +criptors) DT: 2008-Jan-01 00:00:00 UTC (GMT +0000) Channel: Toll: channel = seven ref: ref = xxx.xxxxxx.xxx.xxxxx.xxxxxxx tids: tids = 123456789 ---->Variation 3 (Provides a header, removes descriptors from data. Could easily be revised to push each item to an AoA for further proces +sing, already explained elsewhere.) DATETIME Channel Ref + tids ====================================================================== +======================== 2008-Jan-01 00:00:00 UTC (GMT +0000) seven xxx.xxxxxx.xxx.xxxxx.x +xxxxxx 123456789

You'll probably get better help on future questions if you keep in mind that we're not collecting part of the payment you receive from (whatever) toll road agency.


In reply to Re: Comparing Dates and Reoccurance - Part III by ww
in thread Comparing Dates and Reoccurance - Part III by tuakilan

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.