in reply to sending commands to CLI and then appending to end of array with push

This sounds like you are having some confusion with how scoping operates in Perl. If you have a value stored in a lexically scoped variable, that variable will fall out of scope at the end of your block, and hence you can no longer access the variable by that name. The solution, of course, is to scope your variables correctly. Since the scope of you @commands_run array is one level up, you need to declare that variable at the block level. Something like:

my @commands_run = (); #<-- moved foreach my $command1 (@commands){ 48 chomp $command1; 49 50 $command_run = $ssh->exec($command1); 51 52 print $command_run; 54 push (@commands_run, $command_run); -- want to push commands +issued into the @commands_run array. 55 56 } 57 #print @commands_run;
  • Comment on Re: sending commands to CLI and then appending to end of array with push
  • Download Code