3 # Write a program that works like mv, renaming the first
4 # command-line argument to the second command-line argument. (You
5 # don't need to handle any of the options of mv or additional
6 # arguments.) Remember to allow for the destination to be a
7 # directory; if it is, use the same original basename in the new
14 use File::Spec::Functions;
17 if (scalar(@ARGV) != 2) {
18 die "Usage: $0 source target";
20 my ($source, $target) = @ARGV;
22 $target = catfile($target, basename($source));
25 rename $source $target or die "Unable to move "$source" to "$target": $!";