CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [mpride] Net::FTP - Returing 'Bad remote filename" error: Edit Log

Veteran / Moderator

Dec 29, 2012, 7:21 AM

Views: 2950
Re: [mpride] Net::FTP - Returing 'Bad remote filename" error

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.

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:


use strict;
use warnings.

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 -
File::Find::Rule -

Similarly, Instead of the system call to the rm command, you should be using Perl's unlink function.
perldoc -f unlink


@array = <list>;

That is not going to do what you expect and will generate several warnings.

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)

Edit Log:
Post edited by FishMonger (Veteran) on Dec 29, 2012, 7:22 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives