I recommend using the 'in-place' command line parameter (like mentioned in
in-place edit, regex, one-liner and covered extensivly in
perlrun.
As a sidenote:
flock is pretty handy :)
Update: Ok, I obviously misread the question (could it be the formatting??). Anyway, look at
merlyn's answer.
Greetz
Beatnik
... Quidquid perl dictum sit, altum viditur.