The first error would have been caught by use strict;. Don't hide errors; use use strict; use warnings;.
$$reference->[m_emailAddress]
should be
$$reference->{m_emailAddress}
Secondly, you treat $$reference->{m_emailAddress} as a reference to an (anonymous) array of addresses. It is really a reference to a reference to an (anonymous) array that contains one reference to an (anonymous) array of addresses.
$$reference->{m_emailAddress}->[0]
should be
${ $$reference->{m_emailAddress} }->[0]->[0]
What's with references to scalars and the crazy stacking of references?
use strict; use warnings; sub print_record { my ($rec) = @_; print("username: $rec->{m_username}\n"); print("password: $rec->{m_password}\n"); print("email: @{ $rec->{m_email_addresses} }\n"); } my $stg_username = "PerlMonk"; my $stg_password = "VeryGoodPassword"; my @stg_email_addresses = ( "Monk1", "Monk2", "Monk3" ); my $ellab_rec = { m_username => $stg_username, m_password => $stg_password, m_emailAddress => \@stg_email_addresses, }; print_record($ellb_rec);
In reply to Re: Elaborate Records, arrays and references
by ikegami
in thread Elaborate Records, arrays and references
by KyussRyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |