I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2009-11-02 06:15:20-08 by tinuc
How to pass an open session to a subroutine
So this is probably more of a Perl question but I'm having some trouble passing an open session to a subroutine.
This is how I have it initialized: $s = Net::Appliance::Session->new( Host => $ip, );
I'm trying to pass it as an argument to a subroutine:
enterCommands(\$s , \@array);
then here is the part that is messing me up: inside the subroutine:
my ($s , @array) = @_;
then I get an error: Can't call method "cmd" on unblessed reference at ./css-multi-script.pl line 138, <FILE< line 211. line 138 is:
@out1 = ($s)->cmd($line);
Help please, Amir
Direct Responses: 11695 | Write a response
Posted on 2009-11-02 08:11:36-08 by oliver in response to 11690
Re: How to pass an open session to a subroutine
Hi Amir.

Yes this is a Perl language question really. Arguments to subroutines are passed by-copy in Perl, so you can just pass $s directly like enterCommands($s, @array) and it will work. Also, when calling methods on $s you should not use the round brackets: $s->cmd() will work fine.

I think you might want to look at buying a copy of the Learning Perl O'Reilly book which is a good introduction to Perl.

Best of luck,
regards, oliver.
Direct Responses: Write a response