3 # If your operating system supports it, fix up the program from the previous
4 # exercise to allow an optional -s switch before the other arguments to
5 # indicate that you want to make a soft link instead of a hard link. (Even if
6 # you don't have hard links, see whether you can at least make soft links with
13 use File::Spec::Functions;
16 my $symlink = $ARGV[0] eq '-s';
17 shift @ARGV if ($symlink);
18 if (scalar(@ARGV) != 2) {
19 die "Usage: $0 [-s] source target";
21 my ($source, $target) = @ARGV;
23 $target = catfile($target, basename($source));
26 if ($symlink eq '-s') {
27 symlink $source $target or die "Unable to symlink "$source" to "$target": $!";
29 link $source $target or die "Unable to link "$source" to "$target": $!";