Blob


1 #!/usr/bin/perl
3 # If your operating system supports it, write a program to find any symbolic
4 # links in the current directory and print out their values (like ls -l would:
5 # name -> value).
7 use v5.24;
8 use warnings;
9 use strict;
10 use utf8;
11 use File::Spec::Functions;
12 use File::Basename;
13 use Cwd;
15 if (scalar(@ARGV) > 1) {
16 die "Usage: $0 [dir]";
17 }
18 my $dir = shift @ARGV // getcwd();
20 my $path = catfile($dir, '*');
21 my @files = glob "$path";
22 foreach (@files) {
23 if (-l) {
24 printf "%-30s -> %s\n", basename($_), readlink($_);
25 }
26 }