1 #!/usr/bin/env perl 2 use strict; 3 use warnings; 4 use Net::FTP; 5 6 my $host = 'ftp.example.com'; 7 my $user = 'smith'; 8 my $pass = 'secret'; 9 my $dir_name = '/'; 10 my $target_dir = '/var/tmp/ftp-download'; 11 my $tmp_dir = '/var/tmp'; 12 my $last_index_file = '/var/tmp/last-index'; (...) 42 my $ftp = Net::FTP->new($host); 43 $ftp->login($user, $pass); 44 $ftp->cwd($dir_name); 45 my @dir = $ftp->ls(); #### ~/bin# ./test.pl "my" variable $host masks earlier declaration in same scope at ./ftp-test.pl line 42. "my" variable $ftp masks earlier declaration in same scope at ./ftp-test.pl line 43. "my" variable $user masks earlier declaration in same scope at ./ftp-test.pl line 43. "my" variable $pass masks earlier declaration in same scope at ./ftp-test.pl line 43. "my" variable $ftp masks earlier declaration in same scope at ./ftp-test.pl line 44. #### # Append a '/' to directories if needed if ($target_dir ~! m{\/$}) { $target_dir .= '/'; } if ($tmp_dir ~! m{\/$}) { $tmp_dir .= '/'; } #### # Append a '/' to directories if needed $target_dir .= '/' unless ($target_dir =~ m{\/$}); $tmp_dir .= '/' unless ($tmp_dir =~ m{\/$});