in reply to FOREACH Variables

Couldn't you just move the "if ($alarms.." inside the "foreach $key.." loop ?

BTW - why is "use strict;" commented out ?

You should probably change "foreach $key ..." to "foreach my $key...", and "my $cmd=..." instead of $cmd=..." .. but then you do not use $cmd, so just use the backtick without assigning it to anything.

     Potentia vobiscum ! (Si hoc legere scis nimium eruditionis habes)