Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

copy files based on name

by raggmopp (Novice)
on Feb 27, 2013 at 15:37 UTC ( #1020911=perlquestion: print w/ replies, xml ) Need Help??
raggmopp has asked for the wisdom of the Perl Monks concerning the following question:

Hi all:

The title I'm sure sounds familar but I have been unable to find much to help. So I came up with the following but I'm thinking there is a better way.

What I need to do is copy directories and their files based on the directory name. The directory name is assigned by the Oracle SR module, so an example could be "SR1520931" and it is copied to the directory of ".../SR15xxxxx/SR152xxxx/SR1520xxx/"

Here is the section where I question the efficiency

my $ssh = Net::OpenSSH->new($VHOST); ssh->rsync_get({glob => 1, verbose => 1, times => 1}, ($anon_d/'%4sxxxxx'/'%5sxxxx'/'%6sxxx'/$SRdir/\"$df\"), (substr($SRdir +,0,4),substr($SRdir,0,5),substr($SRdir,0,6)));

Using rsync to pull a copy of the dir&files and put them into the appropriate directory.

This works, but is there a better way?

Many thanks

Comment on copy files based on name
Download Code
Re: copy files based on name
by CountZero (Bishop) on Feb 27, 2013 at 17:01 UTC
    If it works, it works. Don't repair it if it ain't broken.

    But you question "the efficiency". Does it go too slow, does it consume too much system resources, ...?

    The rsync process is usually a rather efficient process.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

    My blog: Imperial Deltronics

      I would gauge the performance as OK, maybe even so-so or marginal. With a load on the system it does slow down even more.

      Agreed, rsync is usually the choice. I'm more concerned with the processing to place the files in their appropriate locations.

        Even if you found something faster than the substr function, the benefits will pale when comparing with the time rsync has taken.

        CountZero

        A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

        My blog: Imperial Deltronics

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1020911]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2014-09-18 02:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (104 votes), past polls