in reply to Re^3: about style: use possessive or atomic?
in thread about style: use possessive or atomic?
Hello rsFalse,
Is it true that ($match){1}+ equals to simply $match?
Yes, and the + does nothing here, as you can see with use warnings:
use strict; use warnings; chomp(my $match = <DATA>); chomp( $_ = <DATA>); for my $regex ( "($match){1}+", "($match){1}", "($match)", "($match)+", "($match)+?", ) { print qw(FAIL SUCCESS)[ !! m/\A $regex \z/x ], "\n" } __DATA__ (a|b){2} bbab
Output:
22:21 >perl 1345_SoPW.pl Useless use of greediness modifier '+' in regex; marked by <-- HERE in + m/\A ((a|b){2}){1}+ <-- HERE \z/ at 1345_SoPW.pl line 27, <DATA> li +ne 2. FAIL FAIL FAIL SUCCESS SUCCESS 22:21 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: about style: use possessive or atomic?
by BrowserUk (Patriarch) on Aug 16, 2015 at 13:00 UTC | |
by Athanasius (Archbishop) on Aug 16, 2015 at 13:25 UTC | |
by BrowserUk (Patriarch) on Aug 16, 2015 at 13:41 UTC | |
by Athanasius (Archbishop) on Aug 16, 2015 at 14:13 UTC | |
by stevieb (Canon) on Aug 16, 2015 at 15:20 UTC | |
by LanX (Saint) on Aug 16, 2015 at 20:18 UTC | |
by LanX (Saint) on Aug 16, 2015 at 22:58 UTC | |
by rsFalse (Chaplain) on Aug 16, 2015 at 23:28 UTC | |
|