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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|