On 2007/04/04, at 14:58, Jeff Pang wrote:
How about this?
if ($ARGV[0] eq 'start') {
print "Starting PostgreSQL:\n";
unless (fork) {
exec "su - $PGUSER -c \"$DAEMON -D \'$PGDATA\' ";
}else {
print "ok\n";
exit;
}
} elsif ($ARGV[0] eq 'stop') {
....
}
Or maybe this:
<code>
sub start {
print "Starting PostgreSQL: ", $/;
unless (fork) {
exec qq{su - $PGUSER -c "$DAEMON" -D '$PGDATA'};
}
else {
print "OK", $/;
exit;
}
}
sub stop {
...
}
my %functions = (
start => \&start,
stop => \&stop,
...
);
$functions{$ARGV[0]}->();
</code>
This approach is called 'dispatch table' and is very common on Perl
code.
Good luck! -- Igor Sutton [EMAIL PROTECTED]
PGP.sig
Description: This is a digitally signed message part
