in reply to Re^2: using input as array name
in thread using input as array name

Excellent suggestion, wonder why I never thought of using a case statement in a perl script.. All of this is academic at point as I disabled the strict refs as per the first suggestion and now my script is working as required/expected. The reason I felt it necessary to do this in the first place is to allow my monitoring system to run external commands against multiple pre-defined hosts in attempts to "self-heal" certain problems. Once again, thank you everyone for your input and suggestions.

Replies are listed 'Best First'.
Re^4: using input as array name
by aquarium (Curate) on Oct 15, 2010 at 05:19 UTC
    If the switch would get too much to maintain, if there are many cases, then you could do a similar thing with a hash, with the command line arg being the key in the hash. as far as i know this is not a bad thing to do, as you're not using the arg to construct a variable name as such.
    you mention using external commands to "heal" hosts. from a systems engineer point of view, this is quite dangerous, unless you can categorically rule out all other possibilities for causing a particular pattern of behavior by the hosts. and said patterns sometimes unexpectedly change etc. so plenty of defensive programming is usually necessitated. and be prepared for this kind of thing never being 100%, as it can sometimes cause more problems than it fixes.
    anyway, have fun
    the hardest line to type correctly is: stty erase ^H