Hi, I am new to Perl. I've got a task to convert a given time (e.g, 6 minutes 30 secs or 24 secs 50 millisecs) completely in seconds. Can you please let me know the approach to do this?

I've worked a bit with unix shell scripting. The problem here I see is that we've environmental variables for time in unix/perl so we cannot declare a variable and store a time into it (time in this specific format: 3min 55s, 4s 230ms ).

I've this "time" printed in the logs which I need to display in "seconds". Now, I can do it in another way like extracting this particular time as a string from the logs (string for example: processing completed in 7s 155ms.) and then operate on it. What I wanted to know is that is there any perl function to simplify this process.


In reply to 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.