in reply to How would you handle arrays of arrays?
Update:Added $destination to the copy, open, and warn statements.#!/opt/local/bin/perl use strict; use warnings; use File::Path; use File::Copy; my $source = '/tmp'; my $destination = '.'; my @cfgA = qw( configapp1/conf/dactest1 configapp1/conf/4k_logging.properties configapp1/conf/logging.properties ); my @cfgB = qw( configbbb/b1.0 configbbb/b1.0.config ); foreach (@cfgA, @cfgB) { my ($path, $file) = m|(.*)/(.*)|; &File::Path::mkpath($path,0,0755) unless -d $path; if (-f "$source/$file") { copy("$source/$file", "$destination/$path/"); } elsif (open(IN,">$destination/$path/$file")) { close(IN); } else { warn("Couldn't copy or create $destination/$path/$file!"); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How would you handle arrays of arrays?
by gokuraku (Monk) on Jan 09, 2009 at 16:41 UTC | |
by hbm (Hermit) on Jan 09, 2009 at 19:23 UTC |