Closed p5pRT closed 16 years ago
perl -wle '$_="bk"; print"_=$_\,1=$1" while s/((.))k$2//;print"|$1|"' Use of uninitialized value in concatenation (.) or string at -e line 1. _=\,1=b |b|
perl -wle '$_="bk"; print"_=$_" while s/((.))k$2//;print" | $1 | "' Use of uninitialized value in concatenation (.) or string at -e line 1. _= Use of uninitialized value in concatenation (.) or string at -e line 1. |
---|
As you can see $1 after the while only exists if it has been used during the loop.
Many other variants of this bug exist. e.g. finding the longest repeated substring (up to length 2**16) like this works:
#!perl -l $_=pop;$?++\,!$&while/(.{$?})(?=.*\1)/;print$&
(notice the useless !$&) but fails like this:
#!perl -l $_=pop;$?++while/(.{$?})(?=.*\1)/;print$&
The behaviour changed in Perl 5.10:
reneeb@reneeb-desktop:\~$ /opt/perl510/bin/perl -wle '$_ = "bk"; print "_=$_" while s/((.))k$2//;print " | $1 | "' Use of uninitialized value $2 in regexp compilation at -e line 1. _= Use of uninitialized value $1 in concatenation (.) or string at -e line 1. |
---|
reneeb@reneeb-desktop:\~$ /opt/perl510/bin/perl -wle '$_ = "bk"; print "_=$_\,1=$1" while s/((.))k$2//;print " | $1 | "' Use of uninitialized value $2 in regexp compilation at -e line 1. _=\,1=b Use of uninitialized value $1 in concatenation (.) or string at -e line 1. |
---|
reneeb@reneeb-desktop:\~$
Cheers\, Renee
The RT System itself - Status changed from 'new' to 'open'
@rgs - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#19388 (status was 'resolved')
Searchable as RT19388$