$hash{'foo'} = 1;
$hash{'foo'}{'bar'} = 2;
####
%1 = { bar => 2 };
##
##
##### MyConst.pm #####
package MyConst;
use warnings;
use strict;
use Readonly ();
require Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw();
Readonly::Scalar our $const1 => 1;
Readonly::Array our @array => qw(x y z);
Readonly::Hash our %hash => (abc => 123, def => 456);
sub foo { 'foobar' }
my $package = __PACKAGE__;
no strict 'refs';
while (my $sym = each %{ "$package\::" }) {
# skip internals
next if $sym =~ /^(?:BEGIN|EXPORT|ISA)$/;
if (defined ${ $sym }) {
push @EXPORT, "\$$sym";
}
elsif (defined %{ $sym }) {
push @EXPORT, "\%$sym";
}
elsif (defined @{ $sym }) {
push @EXPORT, "\@$sym";
}
elsif (defined &{ $sym }) {
push @EXPORT, "$sym";
}
}
1;
__END__