http://qs321.pair.com?node_id=11118049

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