while() { if (m/^$newfriend$/) { print "You are already on the list!\n"; exit; } push @friends, $_; }