I am trying to access a specific variable member in the array in perl.
my $array = [];
@{$array} = (
{ 'family' => "abc",
'roles' => {},
},
{ 'family' => "def",
'roles' => {
'member'=>["1234"],
},
},
);
I tried to access the values using
foreach (@{$array}){
print " $_->{'family'} \n";
#This is printing the family value
}
Could someone explain to me how i could access the member field.i tried using $_->roles->{'member'} but this doesn't seem to work. any inputs here would be of great help.
I get the below output..i am not getting any error.
Hash(0x268d35)->roles->{'memeber'}
$_->{'roles'}{'member'}among other ways.$_->{roles}->{member}is an array ref, so you'll need to de-reference it with@{ ... }. Otherwise it'll get again stringified, henceARRAY(...).ARRAY(0x80f5dec)orHASH(0x826afc0)"