Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2015-10-10 13:01 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (256 votes), past polls