Problem: All 12 processes are not being populated into hash.

Reason: unknown. Why dont I see the last 12 from tail -12?

use strict; use warnings; my (%prochash,@parray,@pids,$list,$pid,$time,$cpu,$user,$args); $|=1; push @parray, qx(/usr/bin/ps -ef -o pid,time,pcpu,user,args|/usr/bin/t +ail -12); print scalar @parray,"\n"; foreach (@parray) { $pid = (split)[0]; $time = (split)[1]; $cpu = (split)[2]; $user = (split)[3]; $args = (split)[4]; $prochash{$cpu} = { 'pid' => $pid, 'time' => $time, 'user' => $user, 'args' => $args, }; } use Data::Dumper; print Dumper \%prochash; __DATA__ 12 $VAR1 = { '0.1' => { 'pid' => '10485852', 'time' => '02:16:16', 'args' => '/opt/freeware/ossec/bin/ossec-syscheck +d', 'user' => 'root' }, '0.0' => { 'pid' => '14876814', 'time' => '00:00:00', 'args' => '/bin/bsh', 'user' => 'root' } };
Thank you!

In reply to process table by teamassociated

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.