[ale] attaching an array to a hash

Christopher Fowler cfowler at outpostsentinel.com
Fri Dec 31 09:31:38 EST 2004


What is the best way to attach an array to a hash.  I know I've asked
this question before but I just can not remember how to do it.  

Here is sample:

  $pids{$pid}{'name'} = $name;
  $pids{$pid}{'pid'} = $pid;
  $pids{$pid}{'cmd'}  = $cmd;
  $pids{$pid}{'args'} = @args;

This is part of an init.d program that stays running to make sure that
some programs never terminate.  If they do it will be responsible for
logging an error and then restarting that proggie.  It will keep Java
RMI program running.

Child Handler:

    if($CHILD == 1) {
      my $child_pid = wait;
      my $status = $?;
      foreach my $ref (sort keys %pids) {
        if($child_pid == $ref) {
          print "Process $pids{$ref}{'name'} exited!\n";
          print "  CMD: $pids{$ref}{'cmd'} $pids{$ref}{'args'}\n";
        }
      }
      $CHILD = 0;
    }



Thanks,
Chris




More information about the Ale mailing list