ip ip1 /tftpboot/tc1 ip2 /tftpboot/tc1 /tftpboot/tc3 /tftpboot/tc4 parser p1 /tftpboot/tc1 /tftpboot/tc2 p2 /tftpboot/tc1 p3 /tftpboot/tc1 /tftpboot/tc2 /tftpboot/tc3 #### open (FILE, "< $mapfile") or die ("Unable to read the file $mapfile"); while (my $str = ) { chomp($str); $comp = $1 if $str =~ m{(.*?)}; $cmd = $1 if $str =~ m{(.*?)}; $tc = $1 if $str =~ m{(.*?)}; if ($tc) { push @tc, $tc; } if ( ($str =~ m{}) ) { $hoh{$comp}{$cmd} = {@tc}; #push @{$hoh{$comp}{$cmd}}, { @tc }; next; } elsif ( ($str =~ m{})||($str =~ m{}) ) { undef @tc; undef $tc; next; } else { next; } } # print Dumper \%hoh; #### $VAR1 = { 'ip' => { 'ip1' => { '/tftpboot/tc1' => '/tftpboot/tc1' }, 'ip2' => { '/tftpboot/tc4' => '/tftpboot/tc4', '/tftpboot/tc1' => '/tftpboot/tc3' } }, 'parser' => { 'p2' => { '/tftpboot/tc1' => '/tftpboot/tc1' }, 'p3' => { '/tftpboot/tc3' => '/tftpboot/tc3', '/tftpboot/tc1' => '/tftpboot/tc2' }, 'p1' => { '/tftpboot/tc2' => undef, '/tftpboot/tc1' => '/tftpboot/tc2' } } }; #### $VAR1 = { 'ip' => { 'ip1' => { '/tftpboot/tc1' }, 'ip2' => { '/tftpboot/tc4', '/tftpboot/tc1', '/tftpboot/tc3' } }, 'parser' => { 'p2' => { '/tftpboot/tc1' }, 'p3' => { '/tftpboot/tc3', '/tftpboot/tc1', '/tftpboot/tc2' }, 'p1' => { '/tftpboot/tc1' => '/tftpboot/tc2' } } };