in reply to incrementing a column

perl -i.bak -pe '$_[$#_]eq$_ or$_[@_]=$_;$_.=" ".@_'