#!/usr/bin/perl -w # Fixes up symlinks. # Variant on Larry Wall's filename-fixer. use strict ; my $code = shift or die "Usage: relink.pl perl-expr [ symlink... ]\n"; chomp(@ARGV = ) unless @ARGV ; for (@ARGV) { warn "Not a link: $_\n" and next unless -l ; my $link = $_ ; my $previous_dest = readlink $link ; $_ = $previous_dest ; eval $code ; die $@ if $@ ; unlink $link and symlink $_, $link or warn "Unable to relink '$link' to '$_': $!\n" unless $previous_dest eq $_ ; }