walkingthecow has asked for the wisdom of the Perl Monks concerning the following question:
# THIS IS MAIN SCRIPT #!/usr/bin/perl use warnings; use strict; use Net::SSH::Admin; my $server=$ARGV[0]; my $ssh = Net::SSH::Admin->new ( host => $server, password => $secret, user => 'myacct', timeout => 60 ); $login = $ssh->connect(); if ($login) $ssh->add_account(username=>"bob"); } # AND THIS IS HOW I AM CALLING THE FUNCTION FROM Net::SSH::Admin package Net::SSH::Admin; use warnings; use strict; use Expect; use Socket; use Carp; use fields qw( host user password port ssh_option raw_pty exp_internal exp_debug ti +meout log_stdout expect ostype prompt ); use Net::SSH::Admin::AddAccount; # I REMOVED sub new, sub connect, etc... sub add_account { my Net::SSH::Admin $self = shift; my %args = @_; my $os = $self->{ostype}; my $sub = $ssh->can("${os}_mod_account"); if ( !$sub ) { print "Don't know how to mod_account for $os\n"; } else { $sub->( $ssh, %args ); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Calling subroutines from nested modules
by ikegami (Patriarch) on Aug 28, 2009 at 16:54 UTC | |
by walkingthecow (Friar) on Aug 28, 2009 at 17:05 UTC |