Blame


1 ffd9a51f 2023-08-04 jrmu #!/usr/bin/perl
2 ffd9a51f 2023-08-04 jrmu
3 ffd9a51f 2023-08-04 jrmu # Using the pattern test program, make a pattern that matches if any word (in
4 ffd9a51f 2023-08-04 jrmu # the \w sense of word) ends with the letter 'a'. Does it match 'wilma' but
5 ffd9a51f 2023-08-04 jrmu # not 'barney'? Does it match 'Mrs. Wilma Flintstone'? What about
6 ffd9a51f 2023-08-04 jrmu # 'wilma&fred'? Try it on the sample text file from the Exercises in Chapter
7 ffd9a51f 2023-08-04 jrmu # 7 (and add these test strings if they weren't already in there).
8 ffd9a51f 2023-08-04 jrmu
9 ffd9a51f 2023-08-04 jrmu use warnings;
10 ffd9a51f 2023-08-04 jrmu use strict;
11 ffd9a51f 2023-08-04 jrmu use utf8;
12 ffd9a51f 2023-08-04 jrmu
13 ffd9a51f 2023-08-04 jrmu while (<>) {
14 ffd9a51f 2023-08-04 jrmu chomp();
15 ffd9a51f 2023-08-04 jrmu if (/a\b/) {
16 ffd9a51f 2023-08-04 jrmu print "Matched: |$`<$&>$'|\n";
17 ffd9a51f 2023-08-04 jrmu } else {
18 ffd9a51f 2023-08-04 jrmu print "No match: |$_|\n";
19 ffd9a51f 2023-08-04 jrmu }
20 ffd9a51f 2023-08-04 jrmu }