This seems a lot like homework. Please excuse my presumption if I am incorrect. The general policy around here is that we are happy to help people learn, but we won't do your homework for you because then you are less likely to actually learn. Please qualify it as homework, and then explain the part you are having trouble with.

I also note that the posted code does not compile; Global symbol "@pids" requires explicit package name at line 45. You also put a prototype on your getParameters definition, but violated your prototype in calling it. As per How do I post a question effectively?, please try code snippets before you post so that we can actually help you with the question at hand, rather than being snarky about variable and subroutine definitions.

How can I grep the process Id and store it an array and calculate the time taken by it?

Assuming you repair the bugs listed above, you've already grepped the process Ids and stored them in the array @process_ids. Of course, you are also editing your posted code as I'm writing this, which makes this a moving target.


#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.


In reply to Re: Perl grep the pid and cal time taken by kennethk
in thread Perl grep the process id and calculate time taken by sravs448

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.