http://www.perlmonks.org?node_id=246370

JSchmitz has asked for the wisdom of the Perl Monks concerning the following question:

I am working on a script that goes out to a host and grabs the .lic files for Veritas so we can keep a record of the keys. Any suggestions on how to make this smoother? Seems it should be simpler than this?
#!/usr/bin/perl -w use Net::FTP; $LIC_DIR = "/home/user/admin/keys"; @files = grep(/\.lic$/, readdir(LDIR)); $ftp = Net::FTP->new("ip address") or die "can't + connect: $@\n"; $ftp->login("user", "password") or die "could +n't login\n"; $ftp->cwd("/etc/vx/elm") or die "could +n't change directory\n"; $ftp->binary(); $ftp->quot("prompt"); foreach $x ( @files ) { $x =~ s/.lic/; print "Getting file $x\n"; $ftp->get($x) or die "could +n't get $x: $@\n"; } $ftp->quit; # outta here