Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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?
LanX looking for a good magit tutorial
LanX ... and git in general
[erix]: I've been to Amsterdam before you were born
[LanX]: 1899?
[chacham]: Just paint the white house black again.
dbander snorts
LanX Gesundheit! :)
talexb wonders about dividing developers in those born before the Unix timestamp of zero .. and after. Spoiler: I'm before.
chacham remebers I am a mad scientist

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (12)
As of 2017-08-18 13:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Who is your favorite scientist and why?



























    Results (302 votes). Check out past polls.

    Notices?