How do I group my package imports into a single custom package?

package, perl

Solution

Have a look at `ToolSet`, which does all the dirty import work for you.

Usage example from pod:

Creating a ToolSet:

# My/Tools.pm
package My::Tools;

use base 'ToolSet'; 

ToolSet->use_pragma( 'strict' );
ToolSet->use_pragma( 'warnings' );
ToolSet->use_pragma( qw/feature say switch/ ); # perl 5.10

# define exports from other modules
ToolSet->export(
 'Carp'          => undef,       # get the defaults
 'Scalar::Util'  => 'refaddr',   # or a specific list
);

# define exports from this module
our @EXPORT = qw( shout );
sub shout { print uc shift };

1; # modules must return true

Using a ToolSet:

use My::Tools;

# strict is on
# warnings are on
# Carp and refaddr are imported

carp "We can carp!";
print refaddr [];
shout "We can shout, too!";

/I3az/

Problem

Normally when I am writing the perl program . I used to include following package . ``` use strict ; use warnings ; use Data::Dumper ; ``` Now , I want like this, I will not include all this package for every program . for that I will have these all package in my own package. like following. my_packages.pm ``` package my_packages ; { use strict ; use warnings ; use Data::Dumper; } 1; ``` So, that if I add my_packages.pm in perl program , it needs have all above packages . Actually I have done this experimentation . But I am not able get this things . which means when I am using my_packages . I am not able get the functionality of "use strict, use warnings , use Data::Dumper ". Someone help me out of this problem.....

Original source

Related problems