/usr/share/perl5/IO/All/Link.pm is in libio-all-perl 0.87-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | use strict; use warnings;
package IO::All::Link;
use IO::All::File -base;
const type => 'link';
sub link {
my $self = shift;
bless $self, __PACKAGE__;
$self->name(shift) if @_;
$self->_init;
}
sub readlink {
my $self = shift;
$self->_constructor->(CORE::readlink($self->name));
}
sub symlink {
my $self = shift;
my $target = shift;
$self->assert_filepath if $self->_assert;
CORE::symlink($target, $self->pathname);
}
sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD;
(my $method = $AUTOLOAD) =~ s/.*:://;
my $target = $self->target;
unless ($target) {
$self->throw("Can't call $method on symlink");
return;
}
$target->$method(@_);
}
sub target {
my $self = shift;
return *$self->{target} if *$self->{target};
my %seen;
my $link = $self;
my $new;
while ($new = $link->readlink) {
my $type = $new->type or return;
last if $type eq 'file';
last if $type eq 'dir';
return unless $type eq 'link';
return if $seen{$new->name}++;
$link = $new;
}
*$self->{target} = $new;
}
sub exists { -l shift->pathname }
1;
|