roho has asked for the wisdom of the Perl Monks concerning the following question:
On a side note, the "start of string" anchor (^) in the regex is fine, but if I add an "end of string" anchor to the regex (either '$' or '\z') the match fails. The match should not fail with the addition of an "end of string" anchor, because each string is exactly 2 characters long.
Where is Jeffrey Friedl when you need him? (ha ha) :-)
#!/usr/bin/perl use strict; use warnings; my @txt = ('cc','cz'); for (@txt) { no warnings 'uninitialized'; if (m/^(.)$1/) { print "True \$_ = |$_| \$1 = |$1|\n"; } else { print "False \$_ = |$_| \$1 = |$1|\n"; } use warnings; }
"It's not how hard you work, it's how much you get done."
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How To Remove Warnings From Regex
by Athanasius (Archbishop) on Feb 04, 2024 at 04:22 UTC | |
by roho (Bishop) on Feb 04, 2024 at 04:44 UTC | |
by choroba (Cardinal) on Feb 04, 2024 at 18:19 UTC | |
by roho (Bishop) on Feb 04, 2024 at 19:09 UTC |