http://qs321.pair.com?node_id=745915


in reply to (Mis)Understanding grep...eq $_

grep doesn't search in strings, it searches arrays or lists. It makes no sense to use it on scalars. You give grep a list, and an operation to execute on each element of the list. For example:

my @list= (1,8,3,9,2); my @newlist= grep $_<5, @list; # @newlist would be (1,3,2);

grep is sort of a loop and what you did was create a loop that always loops only once. So the following two lines are practically equivalent

unless ( grep $person_has eq $_, $item ) { unless ( $person_has eq $item ) {