Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: (jeffa) Re: array newbie...(sigh)

by PrakashK (Pilgrim)
on Mar 15, 2002 at 20:03 UTC ( #152071=note: print w/replies, xml ) Need Help??


in reply to (jeffa) Re: array newbie...(sigh)
in thread array newbie...(sigh)

foreach my $pation (@occupation) { `ps -ef|grep -i $pation|grep -v grep|wc -l`; }
Why throw away the results of ps? (What's wrong with using backticks in a void context?)

If the intention is to count the number of instances of interesting programs from the process list, there is no need to repeat the execution of the ps command.

my @programs = qw(netman jobman mailman batchman writer); my @all_procs = `ps -ef`; my %counts; for (@programs) { $counts{$_} = scalar grep {/$_/i} @all_procs; } print "$_ $counts{$_}," for keys %counts; print "\n";
/prakash

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://152071]
help
Chatterbox?
[shmem]: Lady_Aleena: fix it, or delete it ;-)
[Lady_Aleena]: shmem, I'm not sure how.
[shmem]: well, deleting is done with 'rm' :-P
[shmem]: you can break up the chain MP3::Tag->new($_)- >interpolate("\%S ") and test whether MP3::Tag->new($_) is true
[Lady_Aleena]: shmem, no to deletion.
[shmem]: can't help you there since that song is not on my bench
[Lady_Aleena]: shmem, I need to look at MP3::Tag to see how to get the date from one song.

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2017-04-23 22:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (432 votes). Check out past polls.