Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Explaining Autovivication

by almut (Canon)
on Jun 12, 2008 at 01:59 UTC ( [id://691575]=note: print w/replies, xml ) Need Help??


in reply to Explaining Autovivication

Just another example of where Perl automagically creates data structures as needed:

#!/usr/bin/perl use strict; use warnings; my $href; # not initialized for my $key (keys %$href) { # ... do something } use Data::Dumper; print Dumper $href; # --> $VAR1 = {};

which shows that $href has been autovivified to hold a reference to an (empty) hash, simply because you were using the scalar in a way (keys %$href) that would not have worked without such a data structure...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://691575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-09-09 04:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.