Blame


1 ffd9a51f 2023-08-04 jrmu #!/usr/bin/perl
2 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
3 ffd9a51f 2023-08-04 jrmu ##
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.
9 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
10 ffd9a51f 2023-08-04 jrmu ##
11 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
12 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
13 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
14 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
15 ffd9a51f 2023-08-04 jrmu ## using this work.
16 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
17 ffd9a51f 2023-08-04 jrmu ##
18 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
19 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
20 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
21 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
22 ffd9a51f 2023-08-04 jrmu ## using this work.
23 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
24 ffd9a51f 2023-08-04 jrmu ##
25 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
26 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
27 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
28 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
29 ffd9a51f 2023-08-04 jrmu ## using this work.
30 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
31 ffd9a51f 2023-08-04 jrmu ##
32 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
33 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
34 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
35 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
36 ffd9a51f 2023-08-04 jrmu ## using this work.
37 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
38 ffd9a51f 2023-08-04 jrmu ##
39 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
40 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
41 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
42 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
43 ffd9a51f 2023-08-04 jrmu ## using this work.
44 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
45 ffd9a51f 2023-08-04 jrmu ##
46 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
47 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
48 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
49 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
50 ffd9a51f 2023-08-04 jrmu ## using this work.
51 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
52 ffd9a51f 2023-08-04 jrmu ##
53 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
54 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
55 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
56 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
57 ffd9a51f 2023-08-04 jrmu ## using this work.
58 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
59 ffd9a51f 2023-08-04 jrmu ##
60 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
61 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
62 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
63 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
64 ffd9a51f 2023-08-04 jrmu ## using this work.
65 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
66 ffd9a51f 2023-08-04 jrmu ##
67 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
68 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
69 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
70 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
71 ffd9a51f 2023-08-04 jrmu ## using this work.
72 ffd9a51f 2023-08-04 jrmu ## Copyright (C) 2023 by jrmu <jrmu@ircnow.org>
73 ffd9a51f 2023-08-04 jrmu ##
74 ffd9a51f 2023-08-04 jrmu ## Permission is granted to use, copy, modify, and/or distribute
75 ffd9a51f 2023-08-04 jrmu ## this work for any purpose with or without fee. This work is
76 ffd9a51f 2023-08-04 jrmu ## offered as-is, with absolutely no warranty whatsoever. The
77 ffd9a51f 2023-08-04 jrmu ## author is not responsible for any damages that result from
78 ffd9a51f 2023-08-04 jrmu ## using this work.
79 ffd9a51f 2023-08-04 jrmu
80 ffd9a51f 2023-08-04 jrmu # Make a pattern that will match three consecutive copies of whatever is
81 ffd9a51f 2023-08-04 jrmu # currently contained in $what. That is, if $what is fred, your pattern
82 ffd9a51f 2023-08-04 jrmu # should match fredfredfred. If $what is fred|barney, your pattern should
83 ffd9a51f 2023-08-04 jrmu # match fredfredbarney or barneyfredfred or barneybarneybarney or many other
84 ffd9a51f 2023-08-04 jrmu # variations. (Hint: you should set $what at the top of the pattern test
85 ffd9a51f 2023-08-04 jrmu # program with a statement like my $what = 'fred|barney';.)
86 ffd9a51f 2023-08-04 jrmu
87 ffd9a51f 2023-08-04 jrmu use warnings;
88 ffd9a51f 2023-08-04 jrmu use strict;
89 ffd9a51f 2023-08-04 jrmu use utf8;
90 ffd9a51f 2023-08-04 jrmu
91 ffd9a51f 2023-08-04 jrmu my $what = "fred|barney";
92 ffd9a51f 2023-08-04 jrmu
93 ffd9a51f 2023-08-04 jrmu while (<>) {
94 ffd9a51f 2023-08-04 jrmu chomp;
95 ffd9a51f 2023-08-04 jrmu if (/($what){3}/) {
96 ffd9a51f 2023-08-04 jrmu print ("Match: $_\n");
97 ffd9a51f 2023-08-04 jrmu } else {
98 ffd9a51f 2023-08-04 jrmu print ("Not matched: $_\n");
99 ffd9a51f 2023-08-04 jrmu }
100 ffd9a51f 2023-08-04 jrmu }