package MyPackage; use base qw( Exporter ); @EXPORT = qw( foo ); # create subroutines and export them BEGIN{ for my $sub_name ( qw( bar baz ) ){ *$sub_name = sub { print $sub_name }; push @EXPORT, $sub_name; } } # define a static subroutine for comparison sub foo { print 'foo' } 1;