Dec 29, 2012, 7:21 AM
The first problem I noticed was that you didn't include the strict pragma, which should be in every Perl script you write. The strict pragma will require you to declare your vars prior to using them, which is normally done with the 'my' keyword.
Re: [mpride] Net::FTP - Returing 'Bad remote filename" error
The warnings pragma should also be used instead of the -w switch. The switch and pragma do almost the same thing. The key difference is the switch is applied globally and can not be disabled if need be, whereas the pragma is lexically scoped and can be enabled/disabled at the block level.
So, your scripts should always begin like this:
Instead of making a system call to the find command where you redirect its output, it would be more efficient to use Perl's File::Find or File::Find::Rule module to retrieve and store the file list in an array directly without the intermediate step of the external file.
File::Find - http://search.cpan.org/~dom/perl-5.12.5/lib/File/Find.pm
File::Find::Rule - http://search.cpan.org/~rclamp/File-Find-Rule-0.33/lib/File/Find/Rule.pm
Similarly, Instead of the system call to the rm command, you should be using Perl's unlink function.
perldoc -f unlink http://perldoc.perl.org/functions/unlink.html
That is not going to do what you expect and will generate several warnings.
@array = <list>;
You should use the 3 arg form of open, a lexical var for the filehandle, check the return code to make sure it was successful and take proper action if it wasn't.
open my $file_listing_fh, '<', $list or die "failed to open '$list' $!";
(This post was edited by FishMonger on Dec 29, 2012, 7:22 AM)