
adiab
New User
Sep 27, 2011, 3:59 AM
Post #1 of 3
(1081 views)
|
|
Adding element to a hash
|
Can't Post
|
|
Hi, I'm having problems adding a elements to a hash. I have the hash definied as follows:
$graphs{memory} = { config => { args => '--base 1024 --lower-limit 0', vlabel => 'Bytes Used', category => 'memcached', title => 'Memory Usage', info => 'This graph shows the memory consumption of memcached', }, datasrc => [ { name => 'limit_maxbytes', draw => 'AREA', label => 'Maximum Bytes Allocated', min => '0' }, { name => "bytes.port", draw => 'AREA', label => 'Current Bytes Used', min => '0' }, ], }; and somewhere else in the code I have an if clause which I need to add the new elements:
foreach my $port (@ports){ $graphs{memory} -> {datasrc} => { name => "bytes.$port", draw => 'LINE', label => 'Current Bytes Used', min => '0' }; } The code inside the foreach loop doesn't seem to add anything to my hash. I'm using Data::Dumper to print out the whole thing, but I can't see anything different. Am I missing something obvious? Thx, Amro
|