in reply to Alternative to NET::FTP

You don't need to fully install Net::FTP to use it. See Using modules without admin privelages (yes, spelled like that).

Replies are listed 'Best First'.
RE: Re: Alternative to NET::FTP
by aedificum (Sexton) on Jun 20, 2000 at 01:32 UTC
    O.K., I did that and I think that it is almost working but my script is not actually finding the module..

    I get an error: Can't call "new" in empty package "Net:FTP"

    I have tried playing around with the directory listing in the use lib statement but nothing seems to work.

    Here is a refined version of my original code with some of the bugs removed:

    use lib "script/libnet/Net/FTP.pm"; $ftp = Net::FTP->new("ftp.mycompany.com"); $ftp->login("anonymous","anonymous"); $ftp->ascii; chdir( "$dir/$output" ); opendir( DIR, "$dir/output" ); @files = readdir( DIR ); # transfer all of the output files # in the output directory to SAP. foreach( @files ) { $filehandle = $_; $ftp->put("output/$filehandle"); unlink( "$filehandle" ); } # end foreach $ftp->quit;
      Using a module that's not installed in the normal places Perl looks always takes an extra step:
      use lib '/your/module/directory';
      After you do that, Perl will look in that directory for any subsequent modules you load. You still have to load Net::FTP:
      use Net::FTP; # after the earlier use statement
      So you need both those steps (point Perl at the right place, then load the module). You can't compress it into one, as you're trying to do.

      Ahh, merlyn is being a little coy. You want: use lib <path to library>; Don't specify the particular module. You import that with: use <module name>; In the case of Net::FTP, you can translate the double colons into a directory separator. And your 'use lib' statement ought to point to the directory in which Perl should start looking for Net::FTP (on Unix systems, Perl looks in each of the library locations for Net/FTP.pm).

      Get the picture? You're giving it too much information, and it's looking for script/libnet/Net/FTP.pm/Net/FTP.pm.

      You could use require, but try trimming your path and you'll have better luck. (Oh, and you also might want to use Net::FTP somewhere before you call Net::FTP::new(), too.)

        I was hoping that it instructs the interpreter to 'use' FTP.pm. If I really DID know what it meant, I wouldn't have asked for help :) If you know what it does, then can you please correct the errors of my ways? I first set my novice eyes on a Perl script a mere 2 weeks ago and I am not, nor ever will, claim to be a programming guru. I was just asking for help.
RE: Re: Alternative to NET::FTP
by aedificum (Sexton) on Jun 20, 2000 at 01:36 UTC
    O.K., I did that and I think that it is almost working but my script is not actually finding the module..

    I get an error: Can't call "new" in empty package "Net:FTP"

    I have tried playing around with the directory listing in the use lib statement but nothing seems to work.

    Here is a refined version of my original code with some of the bugs removed:

    use lib "script/libnet/Net/FTP.pm"; $ftp = Net::FTP->new("ftp.mycompany.com"); $ftp->login("anonymous","anonymous"); $ftp->ascii; chdir( "$dir/$output" ); opendir( DIR, "$dir/output" ); @files = readdir( DIR ); # transfer all of the output files # in the output directory to SAP. foreach( @files ) { $filehandle = $_; $ftp->put("output/$filehandle"); unlink( "$filehandle" ); } # end foreach $ftp->quit;