perl-5.8.8-31 and all other 5.8.8 series execute attached code incorrectly It produces the output: Use of uninitialized value in concatenation (.) or string at test.pl line 71. TBN= A=<DATA>T1<ENDMID></end> TXT Use of uninitialized value in concatenation (.) or string at test.pl line 71. TBN= A=<DATA>T2<ENDMID></end> TXT Use of uninitialized value in concatenation (.) or string at test.pl line 71. TBN= A=<DATA>T3<ENDMID></end> TXT Use of uninitialized value in concatenation (.) or string at test.pl line 71. TBN= A=<DATA>T4<ENDMID></end> TXT Use of uninitialized value in concatenation (.) or string at test.pl line 71. TBN= A=<DATA>T5<ENDMID></end> TXT Use of uninitialized value in concatenation (.) or string at test.pl line 71. TBN= A=<DATA>T6<ENDMID></end> TXT when I replace the my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg; by exactly the same meaning: my $x=$a; my($tmpbname)=$x=~m@<DATA>([^<>]*)@isg; the program produces correct output TBN=T1 A=<APARTMENT>T1<ENDMID></end> TXT TBN=T2 A=<APARTMENT>T2<ENDMID></end> TXT TBN=T3 A=<APARTMENT>T3<ENDMID></end> TXT TBN=T4 A=<APARTMENT>T4<ENDMID></end> TXT TBN=T5 A=<APARTMENT>T5<ENDMID></end> TXT TBN=T6 A=<APARTMENT>T6<ENDMID></end> TXT Description of problem: Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
Created attachment 292361 [details] test program perl -w test.pl then comment my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg; and uncomment my $x=$a; my($tmpbname)=$x=~m@<DATA>([^<>]*)@isg; and perl -w test.pl again
Created attachment 292362 [details] simplified test output 1 my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg; Use of uninitialized value in concatenation (.) or string at test2.pl line 28. TBN= A=<DATA>J1</END> Use of uninitialized value in concatenation (.) or string at test2.pl line 28. TBN= A=<DATA>J2</END> Use of uninitialized value in concatenation (.) or string at test2.pl line 28. TBN= A=<DATA>J3</END> Use of uninitialized value in concatenation (.) or string at test2.pl line 28. TBN= A=<DATA>J4</END> Use of uninitialized value in concatenation (.) or string at test2.pl line 28. TBN= A=<DATA>J5</END> output 2 my $x=$a; my($tmpbname)=$x=~m@<DATA>([^<>]*)@isg; TBN=J1 A=<DATA>J1</END> TBN=J2 A=<DATA>J2</END> TBN=J3 A=<DATA>J3</END> TBN=J4 A=<DATA>J4</END> TBN=J5 A=<DATA>J5</END>
The test program from comment 2 works on on Fedora 8 with $ rpm -q perl perl-5.8.8-33.fc8.x86_64 Proposing to close with CURRENTRELEASE.
On F7 it does not produce correct output. I did not try yet on F8. # rpm -q perl perl-5.8.8-28.fc7 # perl -w test2.pl Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J1</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J2</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J3</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J4</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J5</END>
The probles IS NOT FIXED IN rpm -q perl perl-5.8.8-33.fc8 # perl -w test2.pl Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J1</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J2</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J3</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J4</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J5</END> The output IS INCORRECT
(In reply to comment #5) > The probles IS NOT FIXED IN > rpm -q perl > perl-5.8.8-33.fc8 > > # perl -w test2.pl > Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. > TBN= A=<DATA>J1</END> > Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. > TBN= A=<DATA>J2</END> > Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. > TBN= A=<DATA>J3</END> > Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. > TBN= A=<DATA>J4</END> > Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. > TBN= A=<DATA>J5</END> > > The output IS INCORRECT Hmm, I missed that -w -- we really should have use warnings in the source file. By the way, how come that the warning message talks about attachment.cgi when you run perl on test2.pl.
BTW, I've reproduced the problem on 5.8.5 and also on perl-5.8.0-88.7 in RHEL 3.
>By the way, how come that the warning message talks about attachment.cgi when you run perl on test2.pl. It is copy/paste error of the first line. The file with the perl program is attachment.cgi - the one called "simplified test" attached to this report: https://bugzilla.redhat.com/attachment.cgi?id=292362 The correct output, when I comment the line # my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg; and uncomment the lines my $x=$a; my($tmpbname)=$x=~m@<DATA>([^<>]*)@isg; should be this: #perl -w attachment.cgi TBN=J1 A=<DATA>J1</END> TBN=J2 A=<DATA>J2</END> TBN=J3 A=<DATA>J3</END> TBN=J4 A=<DATA>J4</END> TBN=J5 A=<DATA>J5</END> The difference is the TBN= one of strings J1,J2,J3,J4,J5 while with the another code it produces TBN= value of undef
same problem with perl-5.8.8-36.fc8 # rpm -q perl ; perl -w attachment.cgi perl-5.8.8-36.fc8 Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J1</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J2</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J3</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J4</END> Use of uninitialized value in concatenation (.) or string at attachment.cgi line 28. TBN= A=<DATA>J5</END>
FWIW, the test cases also fail on 5.10.0. We may want to file this upstream.
Already is: http://rt.perl.org/rt3/Public/Bug/Display.html?id=50072
Indeed, when looking at that ticket, I agree with the assessment of the p5p commenter, this "bug" is being caused by the /g. Changing: my($tmpbname)=$a=~m@<DATA>([^<>]*)@isg; to my($tmpbname)=$a=~m@<DATA>([^<>]*)@is; Resolves this issue. Closing as NOTABUG. If the original poster disagrees, I suggest that it be directed at upstream, where the ticket is still open.
I just followed the link and read explanations. What I can say. For functions to have a side effect - this happens and sometimes unavoidable. But for OPERATORS to have a side effect is ugly and wrong. But it may be too late to change in perl.
Using /g in your scalar-context match in the if() explicitly requests the side effect. If you don't want it, don't do that then.