By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,848 Members | 1,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,848 IT Pros & Developers. It's quick & easy.

FTP Client

P: 23
I 'm creating a FTP client and i get an error when i try this

Can't locate object method "ls" via package "ftp" (perhaps you forgot to load "f
tp"?) at ftp.pl line 239, <> line 1.



The below is the subroutine, i get input from the user and put the same to an arry and take that again for later usage,

Expand|Select|Wrap|Line Numbers
  1. $ftp = Net::FTP->new($site, Debug => 0)
  2. $ftp->login($un,$pwd);
  3.  
  4. $free = @comm[1];
  5. @list = $ftp->ls($free); # I get the error here !
  6. foreach (@list){
  7. print "\n".$_."\n";
  8. }
  9. prwrkdir();
  10. comm();
  11.  
Jan 9 '08 #1
Share this Question
Share on Google+
3 Replies


numberwhun
Expert Mod 2.5K+
P: 3,503
I 'm creating a FTP client and i get an error when i try this

Can't locate object method "ls" via package "ftp" (perhaps you forgot to load "f
tp"?) at ftp.pl line 239, <> line 1.



The below is the subroutine, i get input from the user and put the same to an arry and take that again for later usage,

Expand|Select|Wrap|Line Numbers
  1. $ftp = Net::FTP->new($site, Debug => 0)
  2. $ftp->login($un,$pwd);
  3.  
  4. $free = @comm[1];
  5. @list = $ftp->ls($free); # I get the error here !
  6. foreach (@list){
  7. print "\n".$_."\n";
  8. }
  9. prwrkdir();
  10. comm();
  11.  
This line:

Expand|Select|Wrap|Line Numbers
  1. $free = @comm[1];
  2.  
should read:

Expand|Select|Wrap|Line Numbers
  1. $free = $comm[1];
  2.  
When you reference an element of an array, the @ changes to a $.

Also, make sure that $comm[1] resolves to a directory as that is what ls() is expecting.


Regards,

Jeff
Jan 9 '08 #2

P: 23
This line:

Expand|Select|Wrap|Line Numbers
  1. $free = @comm[1];
  2.  
should read:

Expand|Select|Wrap|Line Numbers
  1. $free = $comm[1];
  2.  
When you reference an element of an array, the @ changes to a $.

Also, make sure that $comm[1] resolves to a directory as that is what ls() is expecting.


Regards,

Jeff
Thx a lot !!! it worked :D
Jan 9 '08 #3

KevinADC
Expert 2.5K+
P: 4,059
Thx a lot !!! it worked :D
What Jeff said is true, but it would not have fixed your problem. Either you added the "use Net::FTP;" line or the $ftp object is now getting created when you run the new() method. Did you not have $site defined?
Jan 9 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.