in reply to Determining if an element in a list


I'm posting the following alternative mainly as a diversion. The information in perlfaq4 will point you in the right direction, as runrig suggested.

The function takes an array as an argument rather than an array ref. Definitely not for production code. ;-)</t>
#!/usr/bin/perl -w use strict; my @a = (10, 20, 30); my @b = (11, 20, 30); sub item_exists { @_{@_} = 1; $_{$_[0]} ? 0:1; } print "10 ", item_exists(10, @a) ? "is ": "isn't", " in qw(@a).\n"; print "11 ", item_exists(11, @a) ? "is ": "isn't", " in qw(@a).\n"; print "10 ", item_exists(10, @b) ? "is ": "isn't", " in qw(@b).\n"; print "11 ", item_exists(11, @b) ? "is ": "isn't", " in qw(@b).\n";

John.
--