You don't need all those levels of indirect to do what you want to do either.
use strict; use warnings; sub change_record { my ($rec) = @_; $rec->{m_username} = uc($rec->{m_username}); } { my $stg_username = "PerlMonk"; my $stg_password = "VeryGoodPassword"; my @stg_email_addresses = ( "Monk1", "Monk2", "Monk3" ); my $rec = { m_username => $stg_username, m_password => $stg_password, m_emailAddress => \@stg_email_addresses, }; print("username: $rec->{m_username}\n"); change_record($rec); print("username: $rec->{m_username}\n"); }
The $rec inside of change_record is a different variable than the one on the outside (two "my"), but they both hold a reference to the same hash.
In reply to Re^3: Elaborate Records, arrays and references
by ikegami
in thread Elaborate Records, arrays and references
by KyussRyn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |