use strict; use warnings; use Smart::Comments; use lib 'tools'; require 'utils.pl'; use File::Spec; use File::Copy; use File::Path; sub main { while (defined(my $arg = <>)) { chomp $arg; my $rel = File::Spec->file_name_is_absolute($arg) ? File::Spec->abs2rel($arg, $ENV{HOME}) : $arg; my $abs = File::Spec->rel2abs($rel, $ENV{HOME}); my $saved = rel2saved($rel); print "Copying $abs to $saved...\n"; my @path = File::Spec->splitdir($saved); pop @path; mkpath(File::Spec->catdir(@path)); copy($abs, $saved) or die $!; } } main();