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

I have written an application a cut down version of which apears here:
use strict; use Net::FTP; my $server = 'localhost'; my $user = 'user'; my $password = 'pw'; my $targetdir = '.'; my $ftp_file = '../flange'; print("Sending ftp file: ".$ftp_file); my $ftp_session = Net::FTP->new($server, Debug => 1) or die "No ftp co +nnection could be established"; $ftp_session->login($user, $password); $ftp_session->cwd($targetdir); $ftp_session->type("a"); $ftp_session->put($ftp_file); $ftp_session->quit();
The op of this script ends up printing

Can't locate object method "new" via package "Net::FTP::a"
at /home/sjames5//lib/perl5/5.6.0/sun4-solaris/IO/Socket.pm line 162.

I have looked around pm and located other similar problems all of which pertain to old versions of modules. I took a look for a later version of socket.pm and found that the latest version was bundled with my version of perl.
$ perl -v
 
This is perl, v5.6.0 built for sun4-solaris
I would REALLY apreciate any help with this problem.

Thanks
--

Zigster

Replies are listed 'Best First'.
Re: Problem with new failing within Net::FTP
by c-era (Curate) on Feb 22, 2001 at 18:22 UTC
    I've had the same problem with 5.6.0 on sun, but I fixed it by downloading and reinstalling libnet (I left the old files, and had the new installation overwrite them).
      Sigh I just tried tthat .. to no avail.
      --

      Zigster
Re: Problem with new failing within Net::FTP
by smoo (Initiate) on Feb 22, 2001 at 16:52 UTC
    For what it's worth, your code works verbatim on a win32 activestate perl 5.6.0 (build 623). Is there an out of date perl somewhere in your path? Include directories OK?
Re: Problem with new failing within Net::FTP
by pileswasp (Monk) on Feb 23, 2001 at 20:59 UTC
    Hiya, I've got perl 5.004_05 running under RedHat Linux with Net::FTP.pm VERSION = "2.55"; and IO::Socket.pm VERSION = "1.1603"; and I get exactly the same thing.

    There's a very quick and easy way to solve your problem:

    Change the 'a' in the type() function to 'A'.

    Net::FTP::_dataconn sets $pkg = 'Net::FTP::' . $ftp->type; but type never gets specified as uppercase.

    The script needs to look for a /<lib>/Net/FTP/A.pm rather than a /<lib>/Net/FTP/a.pm

    I don't know if this has been fixed in any later versions...?

      Once again the monks come good ;-) Thanks dude that is a spot on fix.
      --

      Zigster
        I flagged this with Graham Barr (the author of Net::FTP). Although in the pod the ascii, binary, etc functions are only listed as synonyms for type, they are, in fact, the 'correct' ways to set the mode. As such,
        $ftp_session->ascii;
        Is the method he recommends to use.
Re: Problem with new failing within Net::FTP
by asmodai (Novice) on Feb 22, 2001 at 19:06 UTC

    I tried the code on FreeBSD 4.2-STABLE with perl 5.005_03 and it worked with no problems.

    Just as a datapoint.

    --Jeroen/Asmodai

      Thanks for your help guys, this is obviously a bad library somewhere I will see if I can track down where it is. *mutter* *mutter*
      --

      Zigster
Re: Problem with new failing within Net::FTP
by princepawn (Parson) on Feb 23, 2001 at 05:15 UTC
    It may be a small point, but why are two forward slashes next to each other in the path to Socket.pm?
    /home/sjames5//lib/perl5/5.6.0/sun4-solaris/IO/Socket.pm
    I'd be curious to see your include path:
    perl -e 'print "@INC"';