You must first
use strict;
use warnings;
then define
my $my_hash;
initialize $my_hashbefore assigning values, because otherwise you overwrite it and all three elements point to the same hash
$my_hash = {};
and finally to access the hash elements
$myarray[$i]->{firstname}
or print the entire hash, you can use Data :: Dumper , for example
print Dumper($myarray[$i])."\n";
- Perl? - Perl?
:
push (@modifymyhash, $myarray[$i]);
, .
foreach my $h (@myarray) {
print Dumper($h), "\n";
}
foreach my $h (@modifymyhash) {
print Dumper($h), "\n";
}
.
, , ith . @modifymyhash
my $copy = {};
%{$copy} = %{$myarray[$i]};
push (@modifymyhash, $copy);