ganesh_mak
09-18-2009, 05:13 PM
I have an array of hashes
#! /usr/bin/perl
my $host_ref;
my @aoh = (
{group_name => 'linux', group_alias => 'LINUX', members => '10'},
{group_name => 'Net', group_alias => 'Net-LINUX', members => '20'},
{group_name => 'SIP', group_alias => 'SIP-LINUX', members => '30'},
{group_name => 'Admin', group_alias => 'Admin-LINUX', members => '10'}
);
foreach my $hostgroup_ref(@aoh){
if($hostgroup_ref->{'membesr'} == 10) {
$hostgroup_ref->{'group_name'} = "MYLINUX"; # does it retain the value #after the loop
}
$host_ref->{'hostgroup'} = $hostgroup_ref;
$hostgroup_ref->{'host'}->{$host_ref->{'host_name'}} = $host_ref;
}
# here if i retreive the value of @aoh
# does it replace the $hostgroup_ref->{'group_name'}=> 'linux' with $hostgroup_ref->{'group_name'} = "MYLINUX";
To replace the value with new one what i have to do there while assiging?
#! /usr/bin/perl
my $host_ref;
my @aoh = (
{group_name => 'linux', group_alias => 'LINUX', members => '10'},
{group_name => 'Net', group_alias => 'Net-LINUX', members => '20'},
{group_name => 'SIP', group_alias => 'SIP-LINUX', members => '30'},
{group_name => 'Admin', group_alias => 'Admin-LINUX', members => '10'}
);
foreach my $hostgroup_ref(@aoh){
if($hostgroup_ref->{'membesr'} == 10) {
$hostgroup_ref->{'group_name'} = "MYLINUX"; # does it retain the value #after the loop
}
$host_ref->{'hostgroup'} = $hostgroup_ref;
$hostgroup_ref->{'host'}->{$host_ref->{'host_name'}} = $host_ref;
}
# here if i retreive the value of @aoh
# does it replace the $hostgroup_ref->{'group_name'}=> 'linux' with $hostgroup_ref->{'group_name'} = "MYLINUX";
To replace the value with new one what i have to do there while assiging?