use strict; use Net::FTP; my $hostname = 'localhost'; my $username = 'slip'; my $password = 'knot'; my $file = 'version.txt'; my ($ftp, $code, $msg); $ftp = Net::FTP->new($hostname); if($@) { print "Error connecting to $hostname: $@"; exit; } $ftp->login($username,$password); $code = $ftp->code; unless ($code == 230) { $msg = $ftp->message; print "Error logging in: $code $msg"; exit; } $ftp->ascii(); $ftp->get($file); $code = $ftp->code; unless ($code == 150 || $code == 226 || $code == 250) { $msg = $ftp->message; print "Error getting $file: $code $msg"; exit; } $ftp->quit;