http://www.perlmonks.org?node_id=808347

Sachin has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I would like to use only Dumper function of Data::Dumper module in my program. So when i use Data::Dumper module then only Dumper function load in memory not all other method of that module. Can anybody tell me is it Possible? if yes then How?
  • Comment on How to call specific method of a module in our program?

Replies are listed 'Best First'.
Re: How to call specific method of a module in our program?
by Corion (Patriarch) on Nov 20, 2009 at 08:29 UTC

    If by "load in memory" you mean "avoid compiling all code in the module", there is no way to make that possible unless the module itself supports it.

    If by "load in memory", you mean "import functions exported by the module", Data::Dumper follows the traditional way of using Exporter to export its subroutines, so you can specify what you want:

    use Data::Dumper qw(Dumper);
      Thanks a Lot Corion!! It's working.
        Are you sure you are not imagining things? Data::Dumper's only export is the sub Dumper, so there shouldn't be any difference between specifying Dumper and not doing it. See the source of Data::Dumper:

        BEGIN { @ISA = qw(Exporter); @EXPORT = qw(Dumper); @EXPORT_OK = qw(DumperX);