in reply to Re^2: error in my code
in thread problem parsing XML into hash

That's not a valid data structure. This is what [id://Perl Mouse] was saying. You've got an odd number of elements in your hash (under 'ip2' and 'p2', infact all of them except 'p1')

UPDATE:

Swapping part of the hash for an array gives you this... Is this any closer?

while (my $str = <DATA>) { chomp($str); $comp = $1 if $str =~ m{<COMP_NAME>(.*?)</COMP_NAME>}; $cmd = $1 if $str =~ m{<CCC_NAME>(.*?)</CCC_NAME>}; if ($str =~ m{<TC_LOC>(.*?)</TC_LOC>}) { push(@{$hoh{$comp}{$cmd}}, $1); } } __OUTPUT__ $VAR1 = { 'ip' => { 'ip1' => [ '/tftpboot/tc1' ], 'ip2' => [ '/tftpboot/tc1', '/tftpboot/tc3', '/tftpboot/tc4' ] }, 'parser' => { 'p2' => [ '/tftpboot/tc1' ], 'p3' => [ '/tftpboot/tc1', '/tftpboot/tc2', '/tftpboot/tc3' ], 'p1' => [ '/tftpboot/tc1', '/tftpboot/tc2' ] } };
---
my name's not Keith, and I'm not reasonable.

Replies are listed 'Best First'.
Re^4: error in my code
by rsennat (Beadle) on Nov 23, 2005 at 12:24 UTC
    Thanks a lot

    I understand that the previous one is not a proper hash, because of having a array in { }, curly braces.

    thanks
    rsennat