Blob
1 #!/usr/bin/perl3 # If you used a directory handle for the previous exercise, rewrite4 # it to use a glob. Or if you used a glob, try it now with a5 # directory handle.7 use v5.24;8 use warnings;9 use strict;10 use utf8;11 use Cwd;13 if (scalar(@ARGV) > 1) {14 die "Usage: $0 [dir]";15 }16 my $dir = shift @ARGV;17 if (!defined($dir) || $dir =~ /\A\s*\z/) {18 chdir or die "Unable to change to $ENV{HOME}: $!";19 } else {20 chdir $dir or die "Unable to change to $dir: $!";21 }23 opendir my $dh, getcwd() or die "Cannot open $dir: $!";24 my @files;25 foreach (sort readdir $dh) {26 next if /\A\.{1,2}\z/;27 print;28 print "\n";29 }