Thanks for the suggestion. This is the Regex that I've come up with:

if($_=~/Launching the JVM/){ /\-+ [A-Za-z]{3} (.*?) (.*?) (.*?)\:(.*?)\:(.*?) (\d+)::(\d+)::Launchi +ng the JVM with following options/; if ( $1 eq "Jan") { $month= "01";} if ( $1 eq "Feb") { $month= "02";} ... if ( $1 eq "Dec") { $month= "12";} if ( $2 eq " 1") { $start_date= "01";} if ( $2 eq " 2") { $start_date= "02";} ... if ( $2 eq " 9") { $start_date= "09";} if ( $3 eq " 1") { $start_hour= "01";} if ( $3 eq " 2") { $start_hour= "02";} ... if ( $3 eq " 9") { $start_hour= "09";} if ( $4 eq "1") { $start_min= "01";} if ( $4 eq "2") { $start_min= "02";} ... if ( $4 eq "9") { $start_min= "09";} if ( $5 eq "1") { $start_sec= "01";} if ( $5 eq "2") { $start_sec= "02";} ... if ( $5 eq "9") { $start_sec= "09";} print "App Start time is: $6-$month-$start_date $start_hour:$start_min +:$start_sec\n";

However, it is failing to convert if the date / hour / min / sec is a single digit / character 0-9 and prints it something like:

$perl get_ts.pl

--------------------------------------

App Start time is: 2015-04- 8 1:51:20

--------------------------------------

Not sure what I am doing wrong. I tried replacing .*? to \d+ but still not getting the desired results.

Can you please suggest?


In reply to Re^2: Need help in extracting timestamp from the line in a file by jayu_rao
in thread Need help in extracting timestamp from the line in a file by jayu_rao

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.