[Image of Linux]
Linux's Witness Ministry
The Personal Web Pages of Chris X. Edwards

ex-foreach.pl

--------------------------
#!/usr/bin/perl
#ex-foreach.pl

@PR=`ps`; #` ` calls to shell for command, ps is a unix command for processes

foreach $x (@PR){ # for each member of the array do the following
  print substr($x, 2, 3), "  "; #substring funtion with 3 arguements= range
  print substr($x, 25);  #substr function with 2 arguements= point to end of string
} #end of statement block

--------------------------
Return to Program Examples
This page was created with only free, open-source, publicly licensed software.
This page was designed to be viewed with any browser on any system.
Chris X. Edwards ~ January 2003