FTP Client

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karthikeyanck
    New Member
    • Oct 2007
    • 23

    FTP Client

    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,

    [code=perl]
    $ftp = Net::FTP->new($site, Debug => 0)
    $ftp->login($un,$pwd );

    $free = @comm[1];
    @list = $ftp->ls($free); # I get the error here !
    foreach (@list){
    print "\n".$_."\n ";
    }
    prwrkdir();
    comm();
    [/code]
    Last edited by numberwhun; Jan 9 '08, 06:32 PM. Reason: add code tags
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    Originally posted by karthikeyanck
    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,

    [code=perl]
    $ftp = Net::FTP->new($site, Debug => 0)
    $ftp->login($un,$pwd );

    $free = @comm[1];
    @list = $ftp->ls($free); # I get the error here !
    foreach (@list){
    print "\n".$_."\n ";
    }
    prwrkdir();
    comm();
    [/code]
    This line:

    [code=perl]
    $free = @comm[1];
    [/code]

    should read:

    [code=perl]
    $free = $comm[1];
    [/code]

    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

    Comment

    • karthikeyanck
      New Member
      • Oct 2007
      • 23

      #3
      Originally posted by numberwhun
      This line:

      [code=perl]
      $free = @comm[1];
      [/code]

      should read:

      [code=perl]
      $free = $comm[1];
      [/code]

      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

      Comment

      • KevinADC
        Recognized Expert Specialist
        • Jan 2007
        • 4092

        #4
        Originally posted by karthikeyanck
        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?

        Comment

        Working...