#!/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!"); } }