in reply to search and give the time difference

I agree with marto, though here's a few hints to get you started.

use strict; use warnings; my @starting = (); my @success = (); my @linetypes = ("Starting", "SUCCESS: Completed"); my $linetypes_re = join("|", @linetypes); my @lines = getAllLinesFromTheBigLogFile__ILeaveItAsAnExerciseToYouToD +oThat(); for my $line (@lines) { chomp $line; # makes life so much easier. next unless $line; my ($linetype, $module, $year, $month, $day, $hh, $mm) = $line =~ +m/^($linetypes_re) (.+$) at (\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})\.$ +/ my $info = [$module, $year, $month, $day, $hh, $mm]; if ($linetype eq $linetypes[0]) { push @starting, $info; } elsif ($linetype eq $linetypes[1]) { push @succes, $info; } }

Beware: code is incomplete and untested and might be full of typos, bugs, logical flaws and other oddities. It's just supposed to get you on the right track.

Replies are listed 'Best First'.
Re^2: search and give the time difference
by raghvens (Novice) on Sep 09, 2011 at 14:05 UTC

    Many Thanks for immediate replies. Sorry I forgot to mention that there are lines in the log file beginning with Starting which need to considered but there are also lines beginning with Starting stop module name - which are not to be considered, Please suggest how to get rid of these lines in the array @linetypes mentioned in the solution provided? I am trying like this, Kindly suggest:

    use strict; use warnings; my @starting=(); my @success=(); my @linetypes = ("Starting", "SUCCESS: Completed"); my $linetypes_re = join("|", @linetypes); open (LG, "path of the os.log"); @log=<LG>; for my $line (@log) { chomp $line; next unless $line; my ($linetype, $moudle, $year, $month, $day, $hh, $mm) = $line =~ +m/^($linetypes_re) (.+$) at (\d{4})-(\d{2})-(\d{2})-(\d{2})(\d{2})\.$ +/ my $info = [$module, $year, $month, $day, $hh, $mm]; if ($linetype eq $linetypes[0]) { push @starting, $info; } elsif ($linetype eq $linetypes[1]) { push @succes, $info; } }