# Test if $copy_from exists: -f $copy_from or die "File '$copy_from' does not exist"; # Test if the directory for $copy_to exists: use File::Basename; my $target_dir = dirname($copy_to); -d $target_dir or die "Target directory '$target_dir' does not exist";