in reply to Grabbing Process Status..
Notes on the changes:while (<BPCONF>) { my ($server) = unpack ("@10 A10", $_); if (($server eq "SERVER = cluster") && ($ps ne "daemon")) { print "Server entry is correct\n"; exit (110); } else { print "Server entry is incorrect\n"; exit (100); } }
Using a regular expression is generally better, especially if you're not sure precisely where the data is going to be, index wise. If you were looking for "SERVER", your code might resemble this:my $server = substr($_, 10, 10); my ($server) = /^.{10}(.{10})/;
while (<BPCONF>) { if (/SERVER = cluster/ && $ps eq "daemon") { print "Server entry is correct\n"; exit (110); } else { print "Server entry is incorrect\n"; exit (100); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Grabbing Process Status..
by raj8 (Sexton) on May 09, 2002 at 02:17 UTC | |
by tadman (Prior) on May 09, 2002 at 08:01 UTC |