1 ffd9a51f 2023-08-04 jrmu #!/usr/bin/perl
2 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
4 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
5 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
6 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
7 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
8 ffd9a51f 2023-08-04 jrmu ## using this work.
10 ffd9a51f 2023-08-04 jrmu # Make a pattern that will match three consecutive copies of whatever is
11 ffd9a51f 2023-08-04 jrmu # currently contained in $what. That is, if $what is fred, your pattern
12 ffd9a51f 2023-08-04 jrmu # should match fredfredfred. If $what is fred|barney, your pattern should
13 ffd9a51f 2023-08-04 jrmu # match fredfredbarney or barneyfredfred or barneybarneybarney or many other
14 ffd9a51f 2023-08-04 jrmu # variations. (Hint: you should set $what at the top of the pattern test
15 ffd9a51f 2023-08-04 jrmu # program with a statement like my $what = 'fred|barney';.)
17 ffd9a51f 2023-08-04 jrmu use warnings;
21 ffd9a51f 2023-08-04 jrmu my $what = "fred|barney";
23 ffd9a51f 2023-08-04 jrmu while (<>) {
25 ffd9a51f 2023-08-04 jrmu if (/($what){3}/) {
26 ffd9a51f 2023-08-04 jrmu print ("Match: $_\n");
28 ffd9a51f 2023-08-04 jrmu print ("Not matched: $_\n");