foreach $k (keys %harry) { $acount = 0; $bcount = 0; if (exists($phash{$k})) { foreach $a(@{$harry{$k}}) { foreach $b(@{$harry{$phash{$k}}}) { if ($a eq $b) { print "$b\n"; #this works as I expect print "$a\n"; #this works as I expect print "${$harry{$phash{$k}}}[$bcount]\n"; #this returns error Use of uninitialized #value in concatenation (.) or string print "${$harry{$k}}[$acount]\n"; #this works as I expect delete ${$harry{$phash{$k}}}[$bcount]; delete ${$harry{$k}}[$acount]; $deletions = $deletions +2; } $bcount = $bcount +1; } $acount = $acount +1; } } }