Blame


1 1ddd2d4e 2023-09-10 jrmu #!/usr/bin/perl
2 1ddd2d4e 2023-09-10 jrmu
3 1ddd2d4e 2023-09-10 jrmu # Read the list of files in the current directory and convert the names to
4 1ddd2d4e 2023-09-10 jrmu # their full path specification. Don't use the shell or an external program
5 1ddd2d4e 2023-09-10 jrmu # to get the current directory. The File::Spec and Cwd modules, both of which
6 1ddd2d4e 2023-09-10 jrmu # come with Perl, should help. Print each path with four spaces before it and
7 1ddd2d4e 2023-09-10 jrmu # a newline after it.
8 1ddd2d4e 2023-09-10 jrmu
9 1ddd2d4e 2023-09-10 jrmu use v5.24;
10 1ddd2d4e 2023-09-10 jrmu use warnings;
11 1ddd2d4e 2023-09-10 jrmu use strict;
12 1ddd2d4e 2023-09-10 jrmu use utf8;
13 1ddd2d4e 2023-09-10 jrmu use File::Spec;
14 1ddd2d4e 2023-09-10 jrmu use Cwd;
15 1ddd2d4e 2023-09-10 jrmu
16 1ddd2d4e 2023-09-10 jrmu my $dir = getcwd();
17 1ddd2d4e 2023-09-10 jrmu opendir my $dh, $dir or die "Unable to read current directory: $!";
18 1ddd2d4e 2023-09-10 jrmu foreach (readdir($dh)) {
19 1ddd2d4e 2023-09-10 jrmu if ($_ eq "." || $_ eq "..") {
20 1ddd2d4e 2023-09-10 jrmu next;
21 1ddd2d4e 2023-09-10 jrmu }
22 1ddd2d4e 2023-09-10 jrmu printf(" %s\n", File::Spec->catfile($dir, $_));
23 1ddd2d4e 2023-09-10 jrmu }