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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |