Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Beginners guide to Net::FTP

by spurperl (Priest)
on Aug 14, 2002 at 10:10 UTC ( #190020=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use strict;           # Don't forget !
    use Net::FTP;
    ...
    
    my $f = Net::FTP->new($host) or die "Can't open $host\n";
    $f->login($user, $password) or die "Can't log $user in\n";
    
  2. or download this
    my $dir = "my/favorite/dir";
    
    $f->cwd($dir) or die "Can't cwd to $dir\n";
    
  3. or download this
    my $file_to_get = "something";
    my $file_to_put = "other something";
    
    $f->get($file_to_get) or die "Can't get $file from $dir\n";
    $f->put($file_to_put) or die "Can't put $file into $dir\n";
    
  4. or download this
    my $file_mdtm = $f->mdtm($file) or die "Can't find $file in $dir\n";
    
  5. or download this
    my $file_mdtm = $f->mdtm($file) or die "Can't find $file in $dir\n";
    
    ...
    {
        print "$file is more than 5 days old\n";
    }
    
  6. or download this
    $, = "\n";
    my @files = $f->ls;
    print @files, "\n";
    
  7. or download this
    $f->ascii();
    $f->binary();
    
  8. or download this
    my $f = Net::FTP->new($host) or die "Can't open $host: $@\n";
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perltutorial [id://190020]
help
Chatterbox?
[Eily]: the overload version wouldn't return true with "$x" && !length $x though, I guess
[hippo]: The more I look at this code, the more $x is a plain old scalar and the more this condition will never be true. I'm calling it a bug at this point.
[hippo]: Thanks for your input which has soothed my sanity (a little)
[Corion]: Eily: Sure - if you force both things into stringy things, then you break that magic. But that would also mean that you changed the expression, as now $x = 0.00 will be true instead of false as it were before
[Corion]: Ah no, at least in my feeble experiments that doesn't change the meaning
[Corion]: We sell sanity in small packages ;)
[Eily]: oh, boolean context uses the "" overload if no bool overload has been defined

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-07-27 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (414 votes). Check out past polls.