eandalu has asked for the wisdom of the Perl Monks concerning the following question:

Hi, When I try to run the following script I get this: Can't locate object method "New" via package "Net::SSH" at
use strict; use warnings; use Net::SSH(); my $Host = "ip1.ip2.ip2.ip4"; my $Port = "1234"; my $passwd = "psw"; my $username = "user"; my $t = New Net::SSH(Timeout => 30); $t->open(Host => $Host,Port => $Port); $t->errmode("return"); $t->waitfor('/:/'); $t->print($username); $t->waitfor('/:/'); $t->print($passwd);
If I use this script:
use strict; use warnings; use Net::SSH::Perl(); my $Host = "ip1.ip2.ip2.ip4"; my $Port = "1234"; my $passwd = "psw"; my $username = "user"; my $t = New Net::SSH::Perl(Timeout => 30); $t->open(Host => $Host,Port => $Port); $t->errmode("return"); $t->waitfor('/:/'); $t->print($username); $t->waitfor('/:/'); $t->print($passwd);
I receive the following error:
C:\>perl SSH3.pl Can't locate Net/SSH/Perl.pm in @INC (@INC contains: C:/Perl64/site/li +b C:/Perl64/lib .) at SSH3.pl line 4. BEGIN failed--compilation aborted at SSH3.pl line 4.
Any suggestion? Many thanks in advance... Andrea

Replies are listed 'Best First'.
Re: Can't locate object method "New" via package "Net::SSH" at
by hdb (Monsignor) on Apr 25, 2013 at 09:56 UTC

    Try new.

      And also, stop using indirect object syntax.
        It is good to provide arguments for a statement like this. Moreover, the "direct" syntax is not much better. The safe ways are either appending ::, which works equally well for both ways, or using the "direct" syntax with quoted class names:
        my $x = new Class::; my $y = Class::->new; my $z = 'Class'->new;
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Can't locate object method "New" via package "Net::SSH" at
by 2teez (Vicar) on Apr 25, 2013 at 10:41 UTC

    Hi eandalu,
    Please always put your codes in <code></code> see How do I post a question effectively?.

    That been said, I think is good to check how a module is implemented before using it at all.
    Check the Net::SSH documentation, it shows a different implementation to what you are trying to do. The module doesn't have an OO implementation, so no object method "New" via package "Net::SSH". But for Net::SSH2 and Net::SSH::Perl there is. However, you need check how it is used.
    Please check these modules documentations.

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me
Re: Can't locate object method "New" via package "Net::SSH" at
by hdb (Monsignor) on Apr 25, 2013 at 10:22 UTC

    If you want to use the module Net::SSH::Perl, you need to install it. For example, like

    cpan install Net::SSH::Perl