Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

alexm's scratchpad

by alexm (Chaplain)
on Jan 05, 2008 at 11:18 UTC ( #660528=scratchpad: print w/replies, xml ) Need Help??

autovivification and symbolic refs


$hash{'foo'} = 1; $hash{'foo'}{'bar'} = 2;
%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).

##### ##### 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__
Log In?

What's my password?
Create A New User
[usemodperl]: corion baby you have done nothing of the sort
[usemodperl]: asking how to download from cpan with core perl via http is unreasonable???
[Corion]: usemodperl: No, asking is not unreasonable. Insisting that it must always keep working for you is unreasonable.
[Corion]: But again, you haven't explained why your users need to download, or why they need to download via http, or why you can't host the SSL-stripper yourself.
[choroba]: Wait a second. Does shutting down mean the cpan clients can no longer use their urllist?
[usemodperl]: i'm under no obligation to explain myself mommy, and i'm not insisting, just asking a simple question
[Veltro]: So, I'm confused on the matter actually. There are locked-down computers, but they need updates. How does that work? Isn't that contradictary?
[usemodperl]: EXACTLY
[usemodperl]: and the https only situation makes it even worse
[Veltro]: How is that 'exactly'. Locked-down means you don't change or update. So why do you need to access CPAN?

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2018-06-24 16:41 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.