develooper Front page | perl.perl5.porters | Postings from December 2004

Re: [perl #32915] "Use of uninitialized value in substitution iterator" while evaluating a string that match /0+[89]\d+/

From:
Tobias Spranger
Date:
December 8, 2004 14:25
Subject:
Re: [perl #32915] "Use of uninitialized value in substitution iterator" while evaluating a string that match /0+[89]\d+/
Message ID:
200412082143.37275.tobispranger@web.de
Hello!

Thank you very much for your responses. Yes, problems with 8 and 9 are very 
suspicious to be octal-decimal-problems ... but I didn't recognize it. After 
Paul's reply I solved this Problem by writing a small subroutine "DEC", that 
simply deletes leading zeros. So my substitution looks like:

$a =~s/($s[0-9]+)/$b.&DEC($1)/ee;

But Yitzchak's solution looks more elegant.

May be it would be usefull to include some pragmas like "use decimal", "use 
octal" or "use numbase 'oct'" to ensure that only a certain base is used. (Or 
maybe there is already such a pargma, that I couldn't find in perlmodlib - 
base is something completely different). So an oktal fan could get a nicer 
output with something like this:

use octal
for (my $i = 06; $i<012; $i++) {print " $i";}

(6 7 10 11 instead of 6 7 8 9)

Greetings,

Tobias



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About