summaryrefslogtreecommitdiff
path: root/eg/relink
diff options
context:
space:
mode:
authorLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-02-28 21:56:43 +0000
committerLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-02-28 21:56:43 +0000
commit9f68db38bddc39fbd37e57bf1751eaf7aac28e57 (patch)
tree8c581f83488d49a072fcad6fb1ebb946d74948df /eg/relink
parentac58e20f744208e9bff2115708a2f1c4e2e2175f (diff)
downloadperl-9f68db38bddc39fbd37e57bf1751eaf7aac28e57.tar.gz
perl 3.0 patch #12 patch #9, continued
See patch #9.
Diffstat (limited to 'eg/relink')
-rw-r--r--eg/relink24
1 files changed, 24 insertions, 0 deletions
diff --git a/eg/relink b/eg/relink
new file mode 100644
index 0000000000..2d8e5f6540
--- /dev/null
+++ b/eg/relink
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+($op = shift) || die "Usage: relink perlexpr [filenames]\n";
+if (!@ARGV) {
+ if (-t) {
+ @ARGV = <*>;
+ }
+ else {
+ @ARGV = <STDIN>;
+ chop(@ARGV);
+ }
+}
+for (@ARGV) {
+ next unless -l; # symbolic link?
+ $name = $_;
+ $_ = readlink($_);
+ $was = $_;
+ eval $op;
+ die $@ if $@;
+ if ($was ne $_) {
+ unlink($name);
+ symlink($_, $name);
+ }
+}