in reply to searching for elements
As per the error message, exists() only works on hash/array elements, so to make use of it, you can add the numbers to a hash (in addition, or instead of the array), and use exists() on that.
grep() should work as well (though slower), but you didn't provide your code. If you are just changing "exists" => "grep { $_ eq $pair }", then that won't work for several reasons (comparing scalar to array, comparing numeric to undefined value, comparing numeric to string). Try instead something like:
redo if $#{[ grep { $_ == $pair } @{$pop{$element}{interactions}} ]}+1;
|
|---|