twintriode
Technical User
Hi All,
I am relatively new to programming and am having some trouble with the following issue. Logically it seems all that would need to be done would make a variable variable and my problem would be solved. Here is the relevant part of my code;
I know now I am using a hash dynamic variable which does not work: $button{$e}= $devices[$d];
What I want is depending on how many devices end up in the @devices array, create the same amount of scalar variables, called:
$button1
$button2
where in this case;
$button1 = "eth1";
$button2 = "eth2";
So how can this be done??
Thanks
I am relatively new to programming and am having some trouble with the following issue. Logically it seems all that would need to be done would make a variable variable and my problem would be solved. Here is the relevant part of my code;
Code:
@devices = ($device, @devices); }
$numdev = $c - "2"; #where $c = 4
print "\nThere are $numdev devices available\n";
#assign values to the devices
$d = 0;
$e = $d + 1;
while ($d < $numdev ){
$button{$e}= $devices[$d];
print "$e - $devices[$d]\n";
$d++;
$e++;
}
What I want is depending on how many devices end up in the @devices array, create the same amount of scalar variables, called:
$button1
$button2
where in this case;
$button1 = "eth1";
$button2 = "eth2";
So how can this be done??
Thanks