Some comments from a fellow "newbie"...  (and my first stab at being
helpful)

File::Copy is a great module, and can handle what you're trying to do.
as others have already said)

On an unrelated note, something that is an immense help to me when using
"or die" is to put $! in the die statement, for example:

or die "Can't open documents: $!";

The $! inserts the "human readable" error returned by the system, such as
"permission denied" or "file not found" which can help a lot in figuring out
what's broke.

-Tony

-----Original Message-----
From: Simopoulos [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 15, 2002 1:19 PM
To: [EMAIL PROTECTED]
Subject: Newbie Stupid Question!


Hi All,
I'm a newbie just starting out learning Perl.
My problem is I have a bunch of files that are (.doc) files, and I want to rename
the files (.data).
I also want move then to another directory, but I don't really want to destroy or
change the old ones (.doc).
What I've done so far doesn't work the way I want it to.  It is:

#! /usr/bin/perl -w
opendir(DOCUMENTS,".") || die "Can't open directory documents!";
@filenames = readdir(DOCUMENTS);
closedir(DOCUMENTS);
foreach $filename(@filenames) {
   if ($filename =~ m/\.doc$/i) {
       rename($filename, "/home/marsie/data/$filename.dat") ||
                          die "Can't move files";
   } else {
       print "Not a .doc file!\n";
   }
}

I would appreciate any help anyone can offer.
Peace,
Marsie


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to