in reply to subroutine For ssh
In addition to the other resources mentioned in this thread, I would suggest the best document to read before going any further with Perl would be perlintro, which contains a section about writing subroutines. The value in perlintro is that it contains just enough on a broad range of Perl topics to inform the rest of your progress toward learning the language, yet takes less than a half hour to read in its entirety.
Learn Perl in about 2 hours 30 minutes is another gem; one that the Mojolicious project lists in its documentation as reference material for people newly coming to Perl.
perlintro takes 20-30 minutes to read. Learn Perl in about 2 hours 30 minutes takes...well, 2 hours and 30 minutes. But the sections on subroutines take about 5 minutes total, and should help you to come to a better understanding.
For your specific case, you need something like this:
sub SSHApp { my ($MyUser, $MyPass, $MyIP) = @_; # ...the rest of your code goes here. # You probably need: # my $output = $ssh_1->cmd('sh version'); return $output; }
Dave
|
|---|