Blame


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