While Corion gave you the better way (Tie::File),
the reason that what you have written isn't working is
that you opened the file as write-only. This means that
The while(<PERS>) loop did nothing. In fact it didn't
even go through the loop. To do what you were wanting to
do you need to use the "+<" open operator instead of ">>" Note: Don't use "+>" unless you want to truncate the file first