01 #!/usr/local/bin/perl -w 02 use strict; 03 use File::Basename; 04 05 my($link) = @ARGV; 06 07 die "No link specified" unless $link; 08 die "$link not a symbolic link" 09 unless -l $link; 10 11 while(-l $link) { 12 $link = readlink($link); 13 } 14 15 $link = dirname($link) unless -d $link; 16 print "$link\n";