Thank you all and thanks Random_Walk for providing the simple solution for this. I loved writing my first simple perl script. :)

Here is the script I created taking a string from the log (though hard coded).

#!/usr/bin/perl my %Minutes = (); my %Seconds = (); my %Seconds1 = (); my %Seconds2 = (); my %TotalTime = (); my %Milliseconds = (); my $statement = "File extraction sucessfully completed in 8s 180ms"; my @values = split(' ', $statement); my $numelements = @values; my $time1 = $values[$numelements-2]; my $time2 = $values[$numelements-1]; if ($time1 =~ m/min/) { $time1 =~ s/[^\d.]//g; $Minutes = $time1; $Seconds1 = $Minutes * 60; } else { $time1 =~ s/[^\d.]//g; $Seconds = $time1; } if ($time2 =~ m/ms/) { $time2 =~ s/[^\d.]//g; $Milliseconds = $time2; $Seconds2 = $Milliseconds / 1000 ; } else { $time2 =~ s/[^\d.]//g; $Seconds = $time2; } $TotalTime = $Seconds1 + $Seconds2 + $Seconds; print "Total time taken: $TotalTime seconds \n";
Suggestions are welcome.

In reply to Re^2: Convert time into seconds by Lucifer
in thread Convert time into seconds by Lucifer

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.