Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

RE: Re: Alternative to NET::FTP

by aedificum (Sexton)
on Jun 20, 2000 at 01:32 UTC ( [id://18881]=note: print w/replies, xml ) Need Help??


in reply to Re: Alternative to NET::FTP
in thread Alternative to NET::FTP

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;

Replies are listed 'Best First'.
RE: RE: Re: Alternative to NET::FTP
by gnat (Beadle) on Jun 20, 2000 at 02:24 UTC
    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.

RE: RE: Re: Alternative to NET::FTP
by chromatic (Archbishop) on Jun 20, 2000 at 01:48 UTC
    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.)

RE: RE: Re: Alternative to NET::FTP
by merlyn (Sage) on Jun 20, 2000 at 01:33 UTC
      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.
        It means you should check the output of perldoc lib a little more closely. The lib pragma adds directories to @INC, but doesn't actually pull any library in.

        -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://18881]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found