App-rsync-new2old
view release on metacpan or search on metacpan
script/rsync-new2old view on Meta::CPAN
if ($r->[0] > $max_mtime) {
$max_mtime = $r->[0];
$max_path = $r->[1];
}
}
return ($max_mtime, $max_path);
}
($mtime, $path);
}
my %Opts = (create_target_if_not_exists => 0);
Getopt::Long::Configure('bundling', 'pass_through', 'no_auto_abbrev', 'permute');
GetOptions(
'help|h|?' => sub {
print <<'_';
Usage: rsync-new2old [options] <source> <target>
Options:
--help, -h, -? Show this message and exit.
--version Show program version and exit.
script/rsync-new2old view on Meta::CPAN
See manpage for more detailed documentation.
_
exit 0;
},
'version' => sub {
no warnings 'once';
print "rsync-new2old version ", ($main::VERSION || "dev"),
($main::DATE ? " ($main::DATE)" : ""), "\n";
exit 0;
},
'create-target-if-not-exists' => \$Opts{create_target_if_not_exists},
);
my ($source, $target);
for (@ARGV) {
if (/\A-/) {
next;
} elsif (!defined($source)) {
$source = $_;
} elsif (!defined($target)) {
$target = $_;
script/rsync-new2old view on Meta::CPAN
}
#use DD; dd {source=>$source, target=>$target, opts=>\%Opts};
die "rsync-new2old: Please specify both source and target\n"
unless defined $source && defined $target;
die "rsync-new2old: Can't find source '$source', must already exist and a local path\n"
unless -e $source;
my ($abs_source, $source_leaf, $source_ends_in_slash) = process_path($source);
my ($abs_target, $target_leaf, $target_ends_in_slash) = process_path($target);
my $real_target = $source_ends_in_slash ? $target : "$abs_target/$source_leaf";
if ($Opts{create_target_if_not_exists}) {
unless (-e $real_target) {
if (-d $source) {
make_path($real_target) or die "rsync-new2old: Can't make_path '$real_target': $!\n";
} else {
open my $fh, ">", $real_target or die "rsync-new2old: Can't create file '$real_target': $!\n";
close $fh;
}
utime 0, 0, $real_target or die "rsync-new2old: Can't set mtime of '$real_target': $!\n";
}
} else {
( run in 0.507 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )