Blob


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