I don't know about 'reliable' but 'how' should work like this:
use Devel::Size qw(total_size);
# code by perrin
my $size_rec_hash = total_size(\%record);
my $size_flag_hash = total_size(\%flag);
print "Total size: $size_rec_hash + $size_flag_hash =",
$size_rec_hash + $size_flag_hash, "\n";
I missed the point, please ignore.
Code written by Hofmator and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.