perl -i -pe '${_}x=$.>1' file [download]
In reply to Re: perl -pie "???" by Anonymous Monk in thread perl -pie "???" by Plankton