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

thats almost the one what i expect.
but please see this format,
$VAR1 = { 'ip' => { 'ip1' => { '/tftpboot/tc1' }, 'ip2' => { '/tftpboot/tc3', '/tftpboot/tc4', '/tftpboot/tc1' } }, 'parser' => { 'p2' => { '/tftpboot/tc1' }, 'p3' => { '/tftpboot/tc2', '/tftpboot/tc3', '/tftpboot/tc1' }, 'p1' => { '/tftpboot/tc2', '/tftpboot/tc1' } } };
thanks

Replies are listed 'Best First'.
Re^3: error in my code
by reasonablekeith (Deacon) on Nov 23, 2005 at 12:08 UTC
    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.
      Thanks a lot

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

      thanks
      rsennat