...
warn sprintf "(Sub)string is [%s]", substr($js,$offset,20);
die $@
...
The function is:
# Take a JSON response and convert it to a Perl data structure
sub to_perl {
my ($self,$js) = @_;
local $_ = $js;
#s/^(\.+\>\s*)+//; # remove Mozrepl continuation prompts
s/^"//;
s/"$//;
if (/\.+>/) {
# This should now be eliminated!
die "Continuation prompt found in [$_]";
}
#warn $js;
# reraise JS errors from perspective of caller
if (/^!!!\s+(.*)$/m) {
croak "MozRepl::RemoteObject: $1";
};
if (! /\S/) {
# We got an empty string back from the REPL ...
warn "Got empty string from REPL";
return;
}
# In the case that we don't have a unicode string
# already, decode the string from UTF-8
$js = decode('UTF-8', $_);
#warn "[[$_]]";
my $res;
local $@;
my $json = $self->json;
if (! eval {
$res = $json->decode($js);
#use Data::Dumper;
#warn Dumper $res;
1
}) {
my $err = $@;
my $offset;
if ($err =~ /character offset (\d+)\b/) {
$offset = $1
};
$offset -= 10;
$offset = 0 if $offset < 0;
warn sprintf "(Sub)string is [%s]", substr($js,$offset,20);
die $@
};
$res
};
As i remember, with previous firefox releases(6.0,5.0,4.0), i encounter this problem occasionally. Now it happens always in firefox 8.
How could avoid this problem?
|