Subject: | LoadCode sometimes fails: Illegal character in prototype |
Hi,
perl -MYAML -e '$YAML::UseCode++; Load(Dump(sub { $_ }))'
Illegal character in prototype for main::CODE : 0x8524dbc at (eval 59)
line 1.
But the above example works with -Mstrict. The reason seems to
be the length difference in the Deparse output. Load gets
confused and attempts to the 'CODE(0x8524dbc)' output causing
the prototype error around YAML/Types.pm line 143
Brad
The attached code produces the following output for me:
Name "YAML::UseCode" used only once: possible typo at
./load_code_fails.pl line 3.
Succeeds
--- !perl/code: |
{
use strict 'refs';
$_++;
}
CODE(0x8527d98) at ./load_code_fails.pl line 9.
Fails
--- !perl/code: "{\n $_++;\n}\n"
Illegal character in prototype for main::CODE : 0x8527be8 at (eval 62)
line 1.
Use of uninitialized value in warn at ./load_code_fails.pl line 16.
Warning: something's wrong at ./load_code_fails.pl line 16.
======
YAML: 0.58
Deparse: 0.7
Perl: 5.008007
Subject: | load_code_fails.pl |
#!/usr/bin/perl -w
use YAML;
$YAML::UseCode=1;
{
use strict;
warn "\nSucceeds\n";
warn $_ = Dump(sub { $_++ });
warn $_ = Load($_);
}
{
no strict;
warn "\nFails\n";
warn $_ = Dump(sub { $_++ });
warn $_ = Load($_);
}
warn <<""
======
YAML: $YAML::VERSION
Deparse: $B::Deparse::VERSION
Perl: $]