Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Explaining Autovivication

by Joost (Canon)
on Jun 12, 2008 at 00:49 UTC ( #691571=note: print w/replies, xml ) Need Help??


in reply to Explaining Autovivication

autovivication basically means that datastructures are automatically expanded at first use.

For instance, if you've got a hash and access a not previously instantiated element and treat it like a hash reference, a hash reference will be created for you:

#!/usr/bin/perl -w use strict; my %hash = (); $hash{a}->{b} = 1; print $hash{a}->{b};
This means you need to do less explicit typing/instantiating, at the cost of possibly accidentally creating structures that aren't there when you mistype.

Note that perl will still throw an error when you for example treat a hash reference as an array reference, so there's still some checking going on.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://691571]
help
Chatterbox?
[Corion]: Meh, I found another Amazon "used" scam reseller... If a product sells for "almost new" at half the price, it's a scam, most likely...
[ambrus]: Corion: that's not true. Actually for Christmas and Thanksgiving, a lot of people buy electronics such as cameras as present, then many of them figure out they don't need it,
[ambrus]: and the electronics gets reselled almost new, but it has to be sold at half price because otherwise everyone chooses to buy the new product which has fewer risk of selling damaged products labelled as almost new.
[ambrus]: You can actually get a lot of useful cheap really almost new products that way, with only a little risk of scams.
[ambrus]: That's what some of the "Black Friday" sales are about.
[Corion]: ambrus: Well, usually, these people don't have in their description "mail me at dodgy_reseller # g m a i l | co m" , replace the "#" by "@" :)
[Corion]: Oh, and the "o" in "com" is a zero

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (11)
As of 2017-11-21 14:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (304 votes). Check out past polls.

    Notices?