"Chip" <> wrote in news:cqednb4QNYIgsBTfRVn-:
> The following prints the system call on
> the screen but does not fill the array.
>
> I don't want the system call to print on
> the screen, and I want to fill the array.
Then you should read the documentation:
perldoc -f system
> #!/usr/bin/perl -w
use warnings;
is preferable. Read more about it in
perldoc warnings
perldoc perllexwarn
> use strict;
> my @array = system("ps ax | grep sendmail");
Once you have read about the backtick operator (see above),
you might still want to avoid spawning the grep above, and
instead use a pipe open to ps, and process the output of the
command line by line. See:
perldoc -f open
> foreach (@array) {
> if ($_ =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) {
That would match things other than IP addresses as well.
See
<URL: http://search.cpan.org/dist/Regexp-Common/lib/Regexp/Common/net.pm>
Sinan
--
A. Sinan Unur <>
(reverse each component and remove .invalid for email address)
comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/cl...uidelines.html