tags:

views:

48

answers:

2
use YAML::XS;
local $YAML::XS::DumpCode=1;
...

Name "YAML::XS::DumpCode" used only once: possible typo at ..

Well, I know I can suppress this specific warning, but it's kind'a ugly. Am I doing anything wrong? I'm not used to be warned :)

A: 

There is no global variable declared with the name $YAML::XS::DumpCode. This configuration is in the YAML class, so you should set it with local $YAML::DumpCode = 1;: see the documentation.

Ether
Eric Strom
@Eric: it's not documented, and there is a documented `$YAML::DumpCode`, so IMHO that variable shouldn't be there at all. The XS should be using `$YAML::DumpCode`.
Ether
@Ether http://search.cpan.org/~ingy/YAML-LibYAML-0.34/lib/YAML/XS.pm#CONFIGURATION explicitly discusses `$YAML::XS::UseCode`.
David B
@David: hmm, this seems really fishy.. why should configs be scattered across the implementation modules when they should just use the ones in `YAML`? But okay, given the documentation, Eric's response is correct. :)
Ether
+3  A: 

It seems like $YAML::XS::DumpCode is only used from C code, and it is never initialized in YAML/XS.pm (it is there, but commented out). So that might be a bug to submit against that module.

In the mean time, no warnings 'once'; should do the trick.

Eric Strom
The same warning goes for `local $YAML::UseCode=1;`. Is that the same case? Anothr bug (this time in `YAML` itself)?
David B
@David => the "other tools" link on every cpan release page contains a grep tool to quickly search all the files in the release. I'd recommend doing a search for `UseCode` and see how it is used in the module.
Eric Strom