Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Introducing myself as a very new beginner in perl so sorry for basic questions as always, but I always get the right answer in perlmonks and I love this place...

so heres my problem. I have a file output which I collect using perl. The output contains several lines of logs each with a timestamp. Now I need to process this output and print just one line out of the output. This line tat I want to print is based on the specific time of the day.

The challenge is the time is epoch time. I have to print say for example the line corresponding to 12:15 AM in the logs by parsing each line of epoch time, convert it to date/time format and then if it matches 12:15, print only that line from the log.

My idea was to import the epoch time into array, convert the epoch time to readable time, then do a condition match. But it turned out to be much more complex than that and I couldnt get it work.

Could someone help me. Here is a sample output: the big numbers like 1375976271 are the epoch time start and end. from this output I want to print the line matching a specific time.
{"DisplayRecords":"12","Records":"12","sColumns":"startTime,endTime, remoteNode,srcIP,srcPort,destIP,destPort,egress,ingress","aaData":[["1 +375976271" ,"1375976430","LAN","D0:05:FE","",1093,"",1330," +1034,348", "0,0"],["1375976246","1375976404","LAN","D0:05:FE","",1092, +"172.20.28 .2",1327,"1034,348","0,0"],["1375976191","1375976381","LAN","D0:05:FE" +,"172.20.3 0.2",1091,"",1324,"1034,348","0,0"],["1375976171","13759763 +14","LAN", "D0:05:FE","",1090,"",1321,"1034,348","0,0"],["1 +375976144" ,"1375976302","LAN","D0:05:FE","",1089,"",1319," +1034,348", "0,0"],["1375975155","1375976089","LAN","D0:05:FE","",1085, +"172.20.28 .2",1278,"1034,348","0,0"],["1375975194","1375975352","LAN","D0:05:FE" +,"172.20.3 0.2",1086,"",1281,"1034,348","0,0"],["1375974693","13759748 +35","LAN", "D0:05:FE","",1083,"",1271,"1034,348","0,0"],["1 +375974668" ,"1375974827","LAN","D0:05:FE","",1081,"",1268," +1034,348", "0,0"],["1375974691","1375974821","LAN","D0:05:FE","",1082, +"172.20.28 .2",1270,"0,0","0,0"],["1375881371","1375881561","LAN","D0:05:FE","172 +.20.30.2", 1055,"",1122,"1034,348","0,0"],["1375881410","1375881540"," +LAN","E0:0 5:AE","",1056,"",1125,"0,0","0,0"]]}

In reply to Epoch based parser by spikeinc

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (4)
    As of 2018-05-26 20:04 GMT
    Find Nodes?
      Voting Booth?