On Apr 27, 2004, at 11:59 AM, Wiggins d Anconia wrote:
The script is as follows:

#!/usr/bin/perl -w

use strict;

my @files = "db1.txt, db2.txt, db3.txt, db4.txt";

foreach (@files) {
    rename "/path/to/pc/file/$_", "/Users/xxxx/Documents/$_".".bak";

You should always check that 'rename' succeeded (as apparently it isn't).


rename $oldfile, $newfile or warn "Can't rename file: $!";

$! will then provide you more information as to why its not working.

I'd be willing to bet that it will be because there's no file called


"/path/to/pc/file/db1.txt, db2.txt, db3.txt, db4.txt"

on your system. Perhaps you mean:

my @files = ("db1.txt", "db2.txt", "db3.txt", "db4.txt");

or just

my @files = qw(db1.txt db2.txt db3.txt db4.txt);


Anyway, Wiggins is right - if you'd checked the error status, $! would have told you...


-Ken



Reply via email to