Perl: the Markov chain saw | |
PerlMonks |
Re: How do I copy files in a dir and continue into each subdir?by pjf (Curate) |
on Oct 03, 2001 at 15:07 UTC ( [id://116409]=note: print w/replies, xml ) | Need Help?? |
File::Find is almost certainly what you're after, although the man page is a bit much to digest if you've never seen it before.
The big power of File::Find lays in the "wanted" function that you pass it. This can do pretty much anything you want. If (for example) you wanted to take each file you find and print it in rot13 to stdout, you could do something like this: If you're copying files, your task is a little more tricky, as you'll need to create directories along the way, and make sure you know where in the source tree you are, and ensure you copy files to the appropriate plate in the destination tree. Personally, if you're just copying trees of files around, I'd suggest you look at good ol' "cp -r" if you're on a UNIX flavoured system. It's much more understandable and obvious, and does its job extremely well. Indeed, doing a "cp -r" and then using File::Find will usually be a simplier problem to solve.
Cheers,
In Section
Seekers of Perl Wisdom
|
|