Blob


1 #!/usr/bin/perl
3 # Modify the previous program to send the output of the command to
4 # a file called ls.out in the current directory. The error output
5 # should go to a file called ls.err. (You don't need to do anything
6 # special about the fact that either of these files may end up
7 # being empty.)
9 use v5.24;
10 use warnings;
11 use strict;
12 use utf8;
14 open STDOUT, '>', 'ls.out' or die "Can't write to ls.out: $!";
15 open STDERR, '>', 'ls.err' or die "Can't write to ls.err: $!";
16 chdir '/' or die "Unable to chdir to '/': $!";
17 exec 'ls', '-l' or die "Unable to run 'ls -l': $!";