I want to write a perlscript that will traverse through a series of subdirectories and print out a dynamic string to a new file that will be executed separately from perlscript that created it. The perlscript would take 2 arguments: directory name and destination server. So if I passed the following 2 arguments to the perlscript:

/opt/oracle/oradata

destServerXYZ

It would generate the following in a file that I would execute later.

cp /opt/oracle/oradata01/redo1.dbf

cp /opt/oracle/oradata01/control1.dbf

cp /opt/oracle/oradata02/redo1.dbf

cp /opt/oracle/oradata03/subdir/usertablespace.dbf

Is there a good way to do this with a perlscript so no matter what server I'm on or directory structure I give, it'll start at the top level of the directory I give and traverse through subdirectories and files to construct the cp statements?

Yes, I accidentially left off the last part. Actually, I'm going to be using rsync instead of cp since I'm going from 1 server to another keeping same directory structure but wanted to be able to use this perlscript as a utility to run on any server giving it the 2 arguments to construct the directories.