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 => 'brayshakes@gmail.com' }; 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 bray.pl line 17."
You could also do this:
#!/usr/bin/perl use strict; use warnings; my %address = ( Bray => { Name => 'Braden Mailloux', Str => 'kapellenstr. 1', EMail => 'brayshakes@gmail.com' }); 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($,,$;,$*,$/)
In reply to Re: References with hashes
by chargrill
in thread References with hashes
by brayshakes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |