Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

copy large number files in different dir's

by Anonymous Monk
on Jun 17, 2004 at 14:52 UTC ( #367645=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, This script works fine for cp file from one path to another. However, need to perfrom this on 50ish dir, is it possible to use an array containing the path locations to cp from and to?
my $folder = '/path//'; find (\&copy, $folder); sub copy { system "cp x /newpath/'; system "cp y /newpath/'; }

Comment on copy large number files in different dir's
Download Code
Re: copy large number files in different dir's
by tinita (Parson) on Jun 17, 2004 at 15:13 UTC
    i don't understand your code example, but i'm guessing:
    use File::Copy; my @paths = ( [qw(/dir1/file /dir2)], [qw(/dir3/file /dir4)], ... ); for (@paths) { my ($from,$to) = @$_; copy($from,$to) or die $!; }
    is that what you want?
      yes, that would work, but it would mean having to change the $from for eac directory. Could i have list of directories and pipe that list into the script?
        The only thing you would need to change is the @paths = () list of directories in the script, not the loop which grabs $from, $to pairs from that list. You could acquire the @paths list from anywhere that provides a list: slurp a file, read from STDIN, etc.

        --
        [ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-09-23 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (241 votes), past polls