c has asked for the wisdom of the Perl Monks concerning the following question:
i am trying to create an object for a module through the following method.
my %args = ( hostname => "router", version = "1" ); my $s = &create_snmp(\%args); sub create_snmp { my $args = shift; my %options; $options{hostname} = $args->{hostname}; $options{version} = $args->{version}; if ($args->{version} == "1") { $options{community} = "public"; } else { $options{username} = "v3user"; $options{password} = "v3pass"; } my $new_session = Net::SNMP->session(\%options); return $new_session; }
This fails and the object is not set. Is this possible and my syntax incorrect, or do I need to look for other ways to correctly return the value?
thanks -c
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: using return to create a module object
by dws (Chancellor) on Jul 06, 2002 at 05:53 UTC | |
by c (Hermit) on Jul 06, 2002 at 13:08 UTC | |
by dws (Chancellor) on Jul 06, 2002 at 17:44 UTC | |
by jeffa (Bishop) on Jul 06, 2002 at 19:07 UTC | |
Re: using return to create a module object
by fokat (Deacon) on Jul 06, 2002 at 17:41 UTC | |
RESOLUTION->Re: using return to create a module object
by c (Hermit) on Jul 07, 2002 at 00:38 UTC |
Back to
Seekers of Perl Wisdom