in reply to Strange memory growth
I don't know if this helps or not, but checking for defined vs or exists can generate hash entries.
Sometimes you have to check at each level if the hash "dimension" exists. A check for "defined" or "exists" can generate automatic dimensions.#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash = ('key' => 'value'); print Dumper \%hash; #prints: #$VAR1 = { # 'key' => 'value' # }; print "defined\n" if defined $hash{abc}{xyz}; # will create new keys print "defined\n" if defined ($hash{x}) and defined ($hash{x}{y}); # a +dded: won't create new keys print "exists\n" if exists ($hash{x}) and exists($hash{x}{y}); # a +dded: won't create new keys print "exists\n" if exists $hash{x1}{x2}; # added: will create new +keys print "defined\n" if defined $hash{x3}; # added: no new key print Dumper \%hash; __END__ #prints: # The "abc" key is created due to the check for defined of 2nd dimensi +on # exists will also create new intermediate keys $VAR1 = { 'key' => 'value', 'abc' => {}, 'x1' => {} };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Strange memory growth
by Anonymous Monk on Feb 15, 2018 at 13:29 UTC | |
by Anonymous Monk on Feb 15, 2018 at 14:13 UTC | |
by Anonymous Monk on Feb 16, 2018 at 14:46 UTC | |
by Marshall (Canon) on Feb 16, 2018 at 21:48 UTC |