Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the YAML CPAN distribution.

Report information
The Basics
Id: 19838
Status: resolved
Priority: 0/
Queue: YAML

Owner: Nobody in particular
Requestors: KENTNL [...]
perlbug [...]

Bug Information
Severity: Unimportant
Broken in:
  • 0.58
  • 0.84
Fixed in: 0.85

Subject: YAML::Dumper synopsis should contain "use YAML"
Download (untitled) / with headers
text/plain 782b
Running the example in the YAML::Dumper synopsis... #!/usr/bin/perl use YAML::Dumper; my $dumper = YAML::Dumper->new; $dumper->indent_width(4); print $dumper->dump({foo => 'bar'}); ...fails for me with... Can't locate object method "global_object" via package "YAML" at /usr/lib/perl5/site_perl/5.8.8/YAML/ line 148. If the synopsis example does a "use YAML;" otoh... #!/usr/bin/perl use YAML; use YAML::Dumper; my $dumper = YAML::Dumper->new; $dumper->indent_width(4); print $dumper->dump({foo => 'bar'}); works fine. Assuming this isn't just me, I guess the easiest fix is perhaps to change the synopsis to include "use YAML;" This is perl 5.8.8, FC5, YAML 0.58. Exact same results on 5.8.6, OS X 10.4, YAML 0.58.

This is still broken in 0.84.

Using the code in YAML::Dumper's synopsis or anything like it fails .

Running the attached script  with

perl -MCarp::Always

Emits the attached output.txt

text/x-perl 175b
#!/usr/bin/env perl use strict; use warnings; use utf8; require YAML::Dumper; my $structure = {}; my $dumper = YAML::Dumper->new(); print $dumper->dump($structure);
Subject: output.txt
Download output.txt
text/plain 419b
Can't locate object method "global_object" via package "YAML" at /home/kent/perl5/perlbrew/perls/perl-5.19.3/lib/site_perl/5.19.3/YAML/ line 146. YAML::Dumper::_prewalk(YAML::Dumper=HASH(0x271d350), HASH(0x20931a8)) called at /home/kent/perl5/perlbrew/perls/perl-5.19.3/lib/site_perl/5.19.3/YAML/ line 35 YAML::Dumper::dump(YAML::Dumper=HASH(0x271d350), HASH(0x20931a8)) called at /tmp/ line 12

It seems trivial to fix however, and you don't have to tell users to "use YAML" to make it work.

Just inject a 'require YAML;'  here:

I might try throw it in and see what happens.

I threw the require pragma in, and the synopsis in YAML::Dumper now works as expected.
Appears to be resolved in 0.85

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to