1 ffd9a51f 2023-08-04 jrmu #!/usr/bin/perl
3 ffd9a51f 2023-08-04 jrmu # Make a program that prints each line of its input that mentions fred. (It
4 ffd9a51f 2023-08-04 jrmu # shouldn't do anything for other lines of input.) Does it match if your
5 ffd9a51f 2023-08-04 jrmu # input string is Fred, frederick, or Alfred? Make a small text file with a
6 ffd9a51f 2023-08-04 jrmu # few lines mentioning "fred flintstone" and his friends, then use that file
7 ffd9a51f 2023-08-04 jrmu # as input to this program and the ones later in this section.
9 ffd9a51f 2023-08-04 jrmu use warnings;
13 ffd9a51f 2023-08-04 jrmu foreach (grep(/fred/, <>)) {
17 ffd9a51f 2023-08-04 jrmu #my @words = <>;
18 ffd9a51f 2023-08-04 jrmu #my @matches = grep(/fred/, @words);
19 ffd9a51f 2023-08-04 jrmu #foreach (@matches) {
20 ffd9a51f 2023-08-04 jrmu # print "$_";