Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: References with hashes

by chargrill (Parson)
on Feb 15, 2007 at 04:50 UTC ( #600133=note: print w/ replies, xml ) Need Help??

in reply to References with hashes

This simple change gets your program closer to working:

#!/usr/bin/perl use strict; use warnings; my %address; $address{Bray} = { Name => 'Braden Mailloux', Str => 'kapellenstr. 1', EMail => '' }; my $email = $address{Bray}->{EMail}; print_address($address{Bray});

After this change, running it only gives the error "Undefined subroutine &main::print_address called at line 17."

You could also do this:

#!/usr/bin/perl use strict; use warnings; my %address = ( Bray => { Name => 'Braden Mailloux', Str => 'kapellenstr. 1', EMail => '' }); my $email = $address{Bray}->{EMail}; print_address($address{Bray});

I believe it has something to do with the hash key not existing as you're trying to declare it lexically, but I couldn't find anything concrete (to me) in the docs. See my and perlsub for more details.

s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

Comment on Re: References with hashes
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2015-10-08 19:04 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (223 votes), past polls