File copy_files.pl of Package dba-php-5411

#!/usr/bin/perl

use File::Basename;

my ($target_dir, $fullname, $basename, $dirname );

$target_dir = $ARGV[0];

if ( (! $target_dir) || (! -d $target_dir) ) {
  print STDERR "Directory $target_dir not found\n";
  exit (1);
}

while (<STDIN>) {
  chomp;
  $fullname = $_;
  $basename = basename($fullname);
  $dirname  = dirname($fullname);
  # print STDOUT "fullname=$fullname, basename=$basename, dirname=$dirname\n";
  if (! -d "$target_dir/$dirname" ) {
    # system("echo mkdir -p $target_dir/$dirname");
    system("mkdir -p $target_dir/$dirname");
  }
  if (! -e "$target_dir/$fullname" ) {
    # system("echo cp -p $fullname $target_dir/$dirname");
    system("cp -p $fullname $target_dir/$dirname");
  }
  # print STDOUT "$fullname\t$dirname\n";
}