listing files Net::FTP
Hi All,
Am trying to use Net::Ftp but unable to list the files available in the ftp server. When I use, $ftp->dir() (or) $ftp->ls() it returns a value like ARRAY(0x89f1092) how to retrieve the file listing from that / Thanks |
Quote:
|
I tried that already, but didnt work !
this is the script and the output Code:
#! /opt/third-party/bin/perl Code:
Net::FTP=GLOB(0x87ca6b0)<<< 226 Closing data connection. Transferred 5280 bytes. |
Try this header:
#!/opt/third-party/bin/perl -w use strict; and note that the string concat in perl is '.', not ',' eg; $ftp->login($user, $pass) || die "Unable to login. ".$ftp->message; Also, it is preferred to use 'or' here, not '||' . |
Quote:
The same output ARRAY(oxhex value) and no files being displayed |
hmm strange, it seems the array is not derefenced. maybe you can try dereferencing and see.
|
Quote:
Excellent that worked! Since the list of files is a long name, I think a reference is returned and not the list of actual files. Not sure of the reason Thanks a lot! |
Quote:
|
Quote:
Could you please explain why it is preferred to use 'or' and not '||'. ? I hope both have got the same meaning ! Thanks :) |
Could you post the resulting code from this?
|
Quote:
Thanks! |
Quote:
|
Quote:
Code:
$var = EXPR1 || EXPR2; #same as $var = ( EXPR1 || EXPR2) Code:
$var = EXPR1 or EXPR2; # same as ( $var = EXPR1) or EXPR2; |
But what difference its going to make,
with Code:
open(FILE, "<", "list") || die "Unable to open file <$!>\n"; Code:
open(FILE, "<", "list") or die "Unable to open file <$!>\n"; Both are definitely the same ! :) |
It is just easier to read this way:
Code:
open(FILE, "<", "list") or die "Unable to open file <$!>\n"; |
All times are GMT -5. The time now is 09:05 AM. |