Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: subroutine For ssh

by davido (Cardinal)
on Oct 08, 2019 at 15:28 UTC ( [id://11107210]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11107210]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-24 18:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found