in reply to How To Remove Warnings From Regex
Hello roho,
Change $1 to \1 within the regex:
use strict; use warnings; my @txt = ('cc', 'cz'); for (@txt) { if (m/^(.)\1$/) { print "True \$_ = |$_| \$1 = |$1|\n"; } else { print "False \$_ = |$_| \$1 = |$1|\n"; } }
Output:
14:13 >perl 2092.SoPW.pl True $_ = |cc| $1 = |c| False $_ = |cz| $1 = |c| 14:14 >
As you can see:
See e.g. Capture groups.
Hope that helps,
| Athanasius <°(((>< contra mundum | סתם עוד האקר של פרל, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How To Remove Warnings From Regex
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 |