perl 3.0 patch #22 patch #19, continued
[p5sagit/p5-mst-13.2.git] / eg / relink
CommitLineData
9f68db38 1#!/usr/bin/perl
2
3($op = shift) || die "Usage: relink perlexpr [filenames]\n";
4if (!@ARGV) {
5 if (-t) {
6 @ARGV = <*>;
7 }
8 else {
9 @ARGV = <STDIN>;
10 chop(@ARGV);
11 }
12}
13for (@ARGV) {
14 next unless -l; # symbolic link?
15 $name = $_;
16 $_ = readlink($_);
17 $was = $_;
18 eval $op;
19 die $@ if $@;
20 if ($was ne $_) {
21 unlink($name);
22 symlink($_, $name);
23 }
24}