http://www.perlmonks.org?node_id=125700


in reply to File Locking

Hmm... Seems like you have empty @friends there. The loop should probably be something like:
while(<MYFILE>) { if (m/^$newfriend$/) { print "You are already on the list!\n"; exit; } push @friends, $_; }
...or one could of course concatenate to the file.

--
Jaska