use File::Copy; # add at the top of your script
## then change rename() to copy() and you should be good. > -----Original Message----- > From: Simopoulos [mailto:[EMAIL PROTECTED]] > Sent: Monday, July 15, 2002 2: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 > > ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]