in reply to data inside file

The criteria for split is not good, because the match will not split columns. Read perlretut and split to see how to write an appropriate regex.

end loop is not valid perl, you ought to comment it f that's what you mean.

Think what happens to the data after the line you updated.

Unless this is home work, there are many modules on the CPAN to help deal with serialized tables of any sort, from CSVs to an SQL server's tables. Perhaps most notable is the AnyData namespace.

-nuffin
zz zZ Z Z #!perl