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

I get the warning:

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 :)

divibisan
  • 11,659
  • 11
  • 40
  • 58
David B
  • 29,258
  • 50
  • 133
  • 186

2 Answers2

18

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
  • 39,821
  • 2
  • 80
  • 152
  • The same warning goes for `local $YAML::UseCode=1;`. Is that the same case? Anothr bug (this time in `YAML` itself)? – David B Oct 22 '10 at 18:38
  • 1
    @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 Oct 22 '10 at 20:27
0

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
  • 53,118
  • 13
  • 86
  • 159
  • Are you sure? The C code seems to use the XS one: `((gv = gv_fetchpv("YAML::XS::DumpCode", TRUE, SVt_PV)) &&` – Eric Strom Oct 22 '10 at 18:18
  • @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 Oct 22 '10 at 18:20
  • http://search.cpan.org/~ingy/YAML-LibYAML-0.34/lib/YAML/XS.pm#CONFIGURATION explicitly discusses `$YAML::XS::UseCode`. – David B Oct 22 '10 at 18:27
  • @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 Oct 22 '10 at 18:34