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

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
perlbug [...] yelsew.com
Cc:
AdminCc:

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/Dumper.pm 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'}); ...it 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 d.pl  with

perl -MCarp::Always d.pl

Emits the attached output.txt

Subject: d.pl
Download d.pl
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/Dumper.pm 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/Dumper.pm line 35 YAML::Dumper::dump(YAML::Dumper=HASH(0x271d350), HASH(0x20931a8)) called at /tmp/d.pl 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: https://metacpan.org/source/MSTROUT/YAML-0.84/lib/YAML/Dumper.pm#L146

I might try throw it in https://github.com/ingydotnet/yaml-pm and see what happens.

I threw the require pragma in, and the synopsis in YAML::Dumper now works as expected.

https://github.com/ingydotnet/yaml-pm/pull/11
Appears to be resolved in 0.85


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

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.