Blob


1 #!/usr/bin/perl
2 ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
3 ##
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
8 ## using this work.
10 # Make a pattern that will match three consecutive copies of whatever is
11 # currently contained in $what. That is, if $what is fred, your pattern
12 # should match fredfredfred. If $what is fred|barney, your pattern should
13 # match fredfredbarney or barneyfredfred or barneybarneybarney or many other
14 # variations. (Hint: you should set $what at the top of the pattern test
15 # program with a statement like my $what = 'fred|barney';.)
17 use warnings;
18 use strict;
19 use utf8;
21 my $what = "fred|barney";
23 while (<>) {
24 chomp;
25 if (/($what){3}/) {
26 print ("Match: $_\n");
27 } else {
28 print ("Not matched: $_\n");
29 }
30 }