copying multiple files

Y

yaduraj

hello all,

How can i copy files with a particular extension.

For eg:
I am using

copy ("$HOME_DIR/file1.txt" ,"$LOCAL_DIR/") or warn "Cannot copy file:
$!";

to copy a file, but if i have to copy all the files with the extension
*.txt how do i do it...

Thanx in advance
 
J

Jim Gibson

yaduraj said:
hello all,

How can i copy files with a particular extension.

For eg:
I am using

copy ("$HOME_DIR/file1.txt" ,"$LOCAL_DIR/") or warn "Cannot copy file:
$!";

to copy a file, but if i have to copy all the files with the extension
*.txt how do i do it...

Perl doesn't have a built-in copy function, so you must be using
File::Copy, If you were to post a complete, minimal program that
demonstrates your problem, people trying to help you wouldn't have to
guess about the details.

To apply a function to different files, check out the glob function or
the File::Find module. You probably want to wrap your copy command in a
loop of some sort, because perl doesn't know whether you want to copy
the each file to a file of the same name in a different directory, or
to a different name in the same directory, or copy all of the files to
a single, concatenated file. You will have to tell it.

FYI: this newsgroup is defunct; try comp.lang.perl.misc in the future.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,023
Latest member
websitedesig25

Latest Threads

Top