RE: beginners-help@perl.org
- From: Clifton.Lee@xxxxxxxxx (Clifton Lee)
- Date: Thu, 27 Dec 2007 10:46:42 -0500
Hello,
The output from the system command may be better stored in a scalar and then
split into an array (separated by return line characters). Then you can use
the 'foreach' operator for each element in your array.
@arr1 = qw/java oracle/;
$scalar = `ps -eo pid,user,pcpu,pmem,args | grep -v grep | grep $arr1[1]`;
@arr2 = split(/\n/, $scalar);
$length = $#arr2;
foreach my $val (@arr2)
{
# get rid of the leading space for each line if one exists
$val =~ s/^\s//;
@arr = split(/\s+/,$val);
print $arr[1]."\n";
}
*******************************************************************************
The views, opinions, and judgments expressed in this message are solely those of the author. The message contents have not been reviewed or approved by the UFT Welfare Fund.
*******************************************************************************
.
- Follow-Ups:
- RE: beginners-help@perl.org
- From: Peter Scott
- Re: beginners-help@perl.org
- From: Chas. Owens
- RE: beginners-help@perl.org
- Prev by Date: Re: beginners-help@perl.org
- Next by Date: Re: replace chars
- Previous by thread: Re: beginners-help@perl.org
- Next by thread: Re: beginners-help@perl.org
- Index(es):
Relevant Pages
|