Search code examples
perloopperl-modulecpanbioperl

How to view the object arguments of a Perl module?


How do I view the arguments/parameters that can be passed to a new object on a Perl module? I usually go to CPAN and look at the SYNPOSIS section for examples of what I'm trying to do. But the examples and the descriptions they provide aren't always comprehensive, and I end up having to look for examples of other people using the module and hope someone has tried to use the module in the same way I am.

Here the latest module I'm trying to use

 use Bio::DB::GenBank;
 my $gb = Bio::DB::GenBank->new(-format     => 'Fasta',
                                -seq_start  => 2,
                                -seq_stop   => 51,
                                -strand     => 1,
                                -complexity => 1);

How do I view the complete list of parameters that I can pass to Bio::DB::GenBank->new(). Is there a way to view the object/object/module definition? Or the object's constructor?

EDIT: I just realized I can download the module from CPAN and look at the code in the module myself for the object parameters but I was wondering if anyone has a better way of doing it?


Solution

  • Modules on CPAN - the way to know for sure is to look at the code, and see what they do. This isn't always particularly straightforward, but it's the one definitive source of truth.

    Otherwise there's the documentation, which is where the developer should have described the (public) module functionality. This doesn't always happen, and sometimes what's clear to the developer, isn't as clear to every potential module user.

    But this is in part, the tradeoff of using a public contribution module library - some modules are so well polished that they gleam, and others are ... well, rather more of a work-in-progress.

    The good news is - most maintainers are receptive to updates and fixes. Often something is 'lacking' simply because of available time, or it meeting the current demands in terms in terms of functionality.