in reply to Re^3: finding neighbors of an element in arrays
in thread finding neighbors of an element in arrays

order in array was important and i arranged them in special order.assume @domain={A,B,C,D},B is a neighbor for A and A and C are neighbors for B.neighbors are elements around an specific element.thanks a lot for your help.

  • Comment on Re^4: finding neighbors of an element in arrays

Replies are listed 'Best First'.
Re^5: finding neighbors of an element in arrays
by jethro (Monsignor) on Jul 28, 2011 at 09:46 UTC

    Ok, your script is nearly there, but you need to be able to store many neighbors for each element, so instead of a hash you need a HashofHashes, see perllol. Just change lines like $h{$element}=$domains1[1]; and replace them with $h{$element}{$domains1[1]}++;

    Why do I have the impression this is just homework? Maybe because a similar question, just with words instead of domains, was posted inside an hour of this one.