in reply to Evolution of a Perl Programmer (new backup script)

Yes, this code is nicer than your first attempt, but there is still some room for improvement. Here are just a couple of things that I noticed (this is just glancing at the code and not really going into it too deeply).
system("rm $ERRORFILE") if -e $ERRORFILE;
Why not just use unlink $ERRORFILE? System calls have a fair amount of overhead and I'm not clear why you would use this instead of a built in function.

Also, you really want to use File::Find for traversing through directories.

Cheers,
Ovid

Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

Replies are listed 'Best First'.
Re: (Ovid) Re: Evolution of a Perl Programmer (new backup script)
by dws (Chancellor) on Dec 21, 2000 at 01:13 UTC
    Another good reason to use unlink() is to avoid the chance that somebody will subvert your script by slipping an executable named rm into your path.

    You could, of course, mitagate this by writing

    system("/bin/rm", $ERRORFILE) if -e $ERRORFILE;
    
    Notice also that I reworked your use of system() to pass two arguments rather than one. This avoids the often unavoidable, albeit small, overhead of having system() check for shell metacharacters.

    Better, I think, to write

    unlink($ERRORFILE) or die "$ERRORFILE: $!"
        if -e $ERRORFILE;