> On Oct 24, 2018, at 9:54 PM, Asad <asad.hasan2...@gmail.com> wrote:
> 
> Thank all now I am able to progress :
> 
> file1  i am able to extract the start and end timestamp 
> file 2  i am able to extract the timestamp 
> 
> used the following 
> my $t1 = Time::Piece->strptime('Feb 23 01:10:28 2018', '%b %d %H:%M:%S %Y'); 
> coming from file1
> 
> my $t2 = Time::Piece->strptime('02/23/18 01:10:33', '%m/%d/%y %H:%M:%S');     
>   coming from file2
> 
> my $t3 = Time::Piece->strptime('Feb 23 01:10:36 2018', '%b %d %H:%M:%S %Y');  
> coming from file 1
> 
> if ($t2 > $t1 and $t2 < $t3) { ... }   till here it working fine
> 
>  now I would like to print all lines from file2 starting from  t2 02/23/18 
> 01:10:33 till very next timestamp which will be  greater than t3 :
> 
> 
> 
> for example the file2  would look like this:
> 
> ===========================================================================================================
> 
>  LOG file opened at 02/23/18 01:10:33
> 
> ERR-05007:   Warning: Intra source concurrency disabled because the 
> preprocessor option is being used.
> 
> Field Definitions for table OPATCH_XML_INV
> 
> eject rows with all null fields
> 
>   Fields in Data Source: 
> 
> 
> 
> ERR-04095:failed: Unable to create patchObject
> 
> Possible causes are:
> 
>  "
> 
>  LOG file opened at 04/26/18 06:10:33
> 
> ===========================================================================================================
>   
> 
> This logfile may have other time but i would to extract only the above lines 
> because messages occured between t1 and t3 after I extract these i want to 
> print the error lines for example ERR-05007
> 
> the issue I am facing if there are multiple error in the file it is printing 
> for each occurance of  ERR-05007 instead it should print only the error lines 
> between t1 and t3 from file2
> 
> Please advice ,
> 
> thanks,

For each line is the file, use a regular expression to look for lines starting 
with ‘LOG file opened at’ and extract the time that follows in that line. Then, 
use Time::Piece to create an object of that class using the date/time 
extracted. Then, you can compare the time in that line to your start and stop 
times in $t2 and $t3 (or is it $t1 and $t3?).


Jim Gibson

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to