in reply to Re^3: Open directory - Different Server
in thread Open directory - Different Server

Hi, I am getting connected using FTP, but when I run this part of the code it can't retrieve the names of the images files in the directory specified earlier.
# Change the working directory $ftp->cwd($path) or die "Can't change directory ($host):" . $ftp->message; # Retrieve a recursive directory listing @ls = $ftp->ls('-lR'); $ftp->binary(); foreach $file (parse_dir(\@ls)) { my($name) = @$file; print "$name<br>"; }

I just don't know why, since the path to the directory is right, and there are many images in that directory.

Replies are listed 'Best First'.
Re^5: Open directory - Different Server
by holli (Abbot) on Feb 22, 2006 at 17:47 UTC
    From the docs:
    ls ( DIR )
    Get a directory listing of DIR, or the current directory.
    In an array context, returns a list of lines returned from the server. In a scalar context, returns a reference to a list.
    So your code should read
    # Retrieve a recursive directory listing @ls = $ftp->ls(); foreach $file ( @ls ) { print "$file<br>"; }


    holli, /regexed monk/
      Thank you, it work!