Subject: | Parser.pm throws warnings when $ch has undef value |
Parser.pm iterates over $ch and does many checks for numeric, string,
etc. It does not check if $ch is undef after every increment, and this
causes warnings to be thrown into the error logs.
The attached file is a patch to fix the problem.
I'm using perl 5.6.2 and $JSON::VERSION=1.05
Subject: | JSON-Parser.pm.diff |
--- JSON/Parser.pm Mon Mar
13 23:21:54 2006
+++ JSON/Parser.pm Tue Mar 21
17:08:57 2006
@@ -236,7 +236,7 @@
my $n = '';
my $v;
- if($ch eq '0'){
+ if(defined $ch && $ch eq '0'){
my $peek = substr($text,$at,1);
my $hex = $peek =~ /[xX]/;
@@ -254,24 +254,24 @@
}
}
- if($ch eq '-'){
+ if(defined $ch && $ch eq '-'){
$n = '-';
next_chr;
}
- while($ch =~ /\d/){
+ while(defined $ch && $ch =~ /\d/){
$n .= $ch;
next_chr;
}
- if($ch eq '.'){
+ if(defined $ch && $ch eq '.'){
$n .= '.';
while(defined(next_chr) and $ch =~ /\d/){
$n .= $ch;
}
}
- if($ch eq 'e' or $ch eq 'E'){
+ if(defined $ch and ($ch eq 'e' or $ch eq 'E')){
$n .= $ch;
next_chr;