Hi all: I'm trying to determine how long an system operation takes. Anyone know of a simple way to do this ? I wanted to establish the start time. Then run the operation. Then mark the finish time. Then substract the start time from the finish time to get an elapsed time. Here's the simplistic approach I tried. I'm sure I need a time that is measured in seconds or something like that, but I'm not sure how to do this. Here's what I tried:
#!/usr/bin/perl -w use warnings; use strict; my $start = "Tue Jan 27 15:40:16 2004"; print "This is the start time: $start \n"; system (This is where the system process stuff goes); my $finish = localtime; print "This is the finish time: $finish \n"; my $elapsedtime = ("$finish" - "$start") ; print "This is the time diff: $elapsedtime \n"; The above obviously didn't work. Here's what it returned: This is the start time: Tue Jan 27 15:40:16 2004 Argument "Tue Jan 27 15:40:16 2004" isn't numeric in subtraction (-) a +t C:\Perl\timetest.pl line 13. This is the finish time: Tue Jan 27 19:45:56 2004 This is the time diff: 0 Argument "Tue Jan 27 19:45:56 2004" isn't numeric in subtraction (-) a +t C:\Perl\timetest.pl line ClearCase\Us
PS. I can't use modules so I will have to do it that way , can someone advice please thanks

In reply to elapsed times by Anonymous Monk

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.