I have a simple foreach loop in Perl that logs into a few different remote hosts and runs a command which returns a numeric value. I want to save this value to a variable. The variable will be named after the individual hostnames (which are being looped through), like below:
host01_backup
host02_backup
etc...
Therefore my question - is it possible to do this within the loop.
foreach $i (@hosts) {
print "hostname is: $i \n";
ssh("ins\@$i", "$cmd"); # this is where I want to assign a variable which is part named using the contents of $i (hostname).
Cheers in advance!