Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
To test this, I'll change Mozilla to Gozilla in the array assignemnt at the top. Since when it loops through, running ps, grepping for Gozilla, it'll get nothing - is that not undefined in this case? In short, if I run the above, grepping for procs that don't exist, I get nothing in standard output. If I'm totally off on that, can someone point me into the direction I need to go in to check for when something WON'T be there?use strict; my @procs = qw|mozilla evolution|; foreach my $process(@procs) { open ( PROCS, "ps -ef |grep $process |grep -v grep|" ) or die "Cou +ldn't open procs $!"; while ( my $proc = <PROCS> ) { chomp $proc; if ( defined( $proc ) ) { print "looks okay here\n"; } else { print "couldn't find $process - you're screwed\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: undefined question
by chromatic (Archbishop) on Jun 09, 2003 at 04:41 UTC | |
by edan (Curate) on Jun 09, 2003 at 07:44 UTC | |
by chromatic (Archbishop) on Jun 09, 2003 at 17:08 UTC | |
by Anonymous Monk on Jun 09, 2003 at 04:46 UTC | |
|
Re: undefined question
by dws (Chancellor) on Jun 09, 2003 at 04:43 UTC | |
by Anonymous Monk on Jun 09, 2003 at 04:53 UTC | |
by dws (Chancellor) on Jun 09, 2003 at 04:58 UTC | |
by Anonymous Monk on Jun 09, 2003 at 06:39 UTC |