head 1.1; branch 1.1.1; access ; symbols ePerl_2_2_14:1.1.1.1 RSE:1.1.1; locks ; strict; comment @# @; 1.1 date 99.05.02.14.43.39; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.05.02.14.43.39; author rse; state Exp; branches ; next ; desc @@ 1.1 log @Initial revision @ text @
@ 1.1.1.1 log @Import of ePerl 2.2.14 @ text @@demo.net
Low-level Network programming with Net::FTP
This demonstrates how one can use the Net::FTP package (from libnet) from within ePerl to retrieve a file via FTP. As an example the ePerl distribution README file is fetched from ftp://ftp.engelschall.com/sw/ while the current filename (ePerl version!) is determined on-the-fly.
And here comes the file:
use Net::FTP; my $tmpfile = "/tmp/demo.net.tmp.$$"; # retrieve the file a temporary file my $ftp = Net::FTP->new("ftp.engelschall.com"); $ftp->login("ftp", "demo.ftp\@@"); $ftp->cwd("/sw"); my ($f) = grep(/^eperl-.*\.readme$/, $ftp->ls("eperl-*.readme")); $ftp->get($f, $tmpfile); $ftp->quit; # read the temporary file into current page open(FP, "<$tmpfile"); while () { print $_; } close(FP); unlink($tmpfile); !>