2 ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
4 ## Permission is granted to use, copy, modify, and/or distribute
5 ## this work for any purpose with or without fee. This work is
6 ## offered as-is, with absolutely no warranty whatsoever. The
7 ## author is not responsible for any damages that result from
10 # Write a program that makes a modified copy of a text file. In the copy,
11 # every string Fred (case-insensitive) should be replaced with Larry. (So,
12 # Manfred Mann should become ManLarry Mann.) The input file name should be
13 # given on the command line (don't ask the user!), and the output filename
14 # should be the corresponding file name ending with .out.
20 if (scalar(@ARGV) != 1) {
21 die "Usage: $0 filename";
23 my $filepath = ($ARGV[0] =~ s/.[^.]*\z/.out/r);
24 open my $fh, ">", $filepath or die "Unable to write to '$filepath': $!";