Blob


1 #!/usr/bin/perl
3 # Write a program that takes multiple directory names from the command line
4 # and then prints out their contents. Use a function that takes a directory
5 # handle reference that you made with opendir.
7 use v5.24;
8 use warnings;
9 use strict;
10 use utf8;
11 use local::lib;
13 use IO::Tee;
15 foreach (@ARGV) {
16 opendir my $dh, $_ or die "Could not open dirhandle! $!\n";
17 print ls($dh);
18 }
20 sub ls {
21 my $dh = shift;
22 my @output;
23 foreach (readdir $dh) {
24 next if /\A\.\.?\z/;
25 push @output, "$_\n";
26 }
27 return @output;
28 }