http://qs321.pair.com?node_id=11106078


in reply to Images with PDF::Builder

Stickybit:

When the documentation of a module doesn't give you quite enough detail, I find it helpful to go to the tests (./t/) directory for the module, and then grep the files to find which tests exercise the function of interest. Then you can see how to call the function. One advantage of this method is that authors try to make the tests as small as possible, so it won't be cluttered up with a bunch of extraneous things you don't need.

I don't have PDF::Builder on my machine, so I just chose a module at random (Ref::Util) from my cpan folder and scanned through the test directory for the test files that use the "is_plain_hashref(" function:

$ grep -r "is_plain_hashref(" .cpan/build/Ref-Util-0.204-0/t/*.t .cpan/build/Ref-Util-0.204-0/t/all-permutations.t: is_p +lain_hashref($value), .cpan/build/Ref-Util-0.204-0/t/all-permutations.t: "is_ +plain_hashref($plain_type) is true", .cpan/build/Ref-Util-0.204-0/t/all-permutations.t: !is_ +plain_hashref($value), .cpan/build/Ref-Util-0.204-0/t/all-permutations.t: "is_ +plain_hashref($plain_type) is false", .cpan/build/Ref-Util-0.204-0/t/all-permutations.t: !is_plai +n_hashref($value), .cpan/build/Ref-Util-0.204-0/t/all-permutations.t: "is_plai +n_hashref($blessed_type) is false", .cpan/build/Ref-Util-0.204-0/t/functions.t: is_plain_hashre +f => is_plain_hashref($value), .cpan/build/Ref-Util-0.204-0/t/magic-readonly.t:ok( is_plain_hashref($ +rh2), 'They are not plain!' );

From here, you can simply look at the test files and see how they do it.

Note: for poorly-tested modules, you may not find anything useful. But in that case, how interested are you in using the module? :^P

...roboticus

When your only tool is a hammer, all problems look like your thumb.