http://qs321.pair.com?node_id=660528

autovivification and symbolic refs

This:

$hash{'foo'} = 1; $hash{'foo'}{'bar'} = 2;
performs:
%1 = { bar => 2 };

Reference: Re^3: Why is my code assigning the last-retrieved value to all elements in my hash?

a way to export all constants instead of listing each one

My response to Re^4: how to create a constant file and use it in other file didn't get much feedback, and it's one that I'm very proud of, so I'm adding it here, just in case someone finds it useful (it was quite entertaining to come up with).

##### 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__