Given the following code, does the hash referenced by $z
consume the same memory as that used by ( %$x, %$y)
, more or less?
If so, is there a way to use a single reference to call data from the hashes referenced by either $x
or $y
like $z->{$somekeytoXorY}
without affecting performance and memory?
use strict;
use warnings;
my $x = {
1 => 'a',
2 => 'b',
};
my $y = {
3 => 'c',
4 => 'd',
};
my $z = {
%$x, %$y
};
Update
The hash references actually point to large hashes created using tie
and DB_File
.
I was wondering whether there is a chance I could use just a single hash to these so that I don't need to dump everything in memory. Also I may be using more than two of these at once.