you show
$hash{'mode'}{'component'} = [{'command' => 'cmd1'}, {'command' => 'cmd2'}];
simplist would be
$hash{'mode'}{'component'} = ['cmd1', 'cmd2'];
but I'd go for
$hash{'mode'}{'component'}{'commands'} = ['cmd1', 'cmd2'];
####
#!/perl -w
use Data::Dumper;
use strict;
my %hash;
my $current_comp = "";
my $current_mode = "";
my %the_hash;
while () {
chomp;
my ($coord,$data) = split /=>/;
my ($row,$col) = split /,/, $coord;
if ($col == 0) {
$current_comp = $data;
next;
}
if ($col == 2) {
$current_mode = $data;
next;
}
if ($col == 4) {
push @{$the_hash{$current_mode}{$current_comp}{'commands'}}, $data;
next;
}
}
print Dumper(\%the_hash);
####
push @{$the_hash{$current_mode}{$current_comp}{'commands'}}, $data;
####
$VAR1 = {
'mode1' => {
'comp3' => {
'commands' => [
'command1',
'command2'
]
},
'comp1' => {
'commands' => [
'command1'
]
}
},
'mode2' => {
'comp2' => {
'commands' => [
'command1',
'command2',
''
]
}
}
};