pl_pm has asked for the wisdom of the Perl Monks concerning the following question:
Hi all,
I have upgraded Perl from v5.24 to v5.30.3 and my script does not work now. The problem is in ${^POSTMATCH}, the following simple script illustrates it:
use warnings; use strict; use v5.10; sub add_incr_suffix { state $suffix = 'A'; return "prefix-TEXT-" . $suffix++; } print 'Test ' . ( add_incr_suffix =~ /^prefix-*/p ? ${^POSTMATCH} : '' ) . "," . ( add_incr_suffix =~ /^prefix-*/p ? ${^POSTMATCH} : '' ) . "," . ( add_incr_suffix =~ /^prefix-*/p ? ${^POSTMATCH} : '' ) . "\n";
Perl v5.24.0 (and v5.26.1] returns the desired result Test TEXT-A,TEXT-B,TEXT-C but both v5.28.0 and v5.30.3 return Test TEXT-C,TEXT-C,TEXT-C.
If I replace string concatenation with join() in the print() statement, all above mentioned versions return Test TEXT-C,TEXT-C,TEXT-C.
Is it a bug or my use case is wrong? Many thanks for your opinion.
Best regards
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: ${^POSTMATCH} problem
by tybalt89 (Monsignor) on Jun 14, 2020 at 13:58 UTC | |
by LanX (Saint) on Jun 14, 2020 at 14:12 UTC | |
by ikegami (Patriarch) on Jun 14, 2020 at 15:34 UTC | |
by LanX (Saint) on Jun 14, 2020 at 16:01 UTC | |
by ikegami (Patriarch) on Jun 15, 2020 at 04:22 UTC | |
| |
Re: ${^POSTMATCH} problem
by Haarg (Priest) on Jun 14, 2020 at 14:09 UTC | |
by LanX (Saint) on Jun 14, 2020 at 14:31 UTC | |
by pl_pm (Initiate) on Jun 21, 2020 at 19:22 UTC | |
Re: ${^POSTMATCH} problem
by LanX (Saint) on Jun 14, 2020 at 13:59 UTC | |
Re: ${^POSTMATCH} problem
by perlfan (Vicar) on Jun 14, 2020 at 14:08 UTC |
Back to
Seekers of Perl Wisdom