# Command execution and export data to local file sub main { my @hosts = get_host(); print @hosts; print "\n"; for my $host (@hosts){ print "For host $host...\n"; my $logon = get_logon(); print $logon . "\n"; my $psswd = get_psswd(); print $psswd . "\n"; my @cmds = get_command(); print @cmds; my $output = qx(cmd); open OUTPUT, '>>' , 'devbfs51chassisshow.txt' or die " Couldn't open output.txt: $!\n"; print $OUTPUT "1plink -ssh -pw $psswd -l $logon $host @cmds"; } close OUTPUT; }