http://qs321.pair.com?node_id=1046122


in reply to One liner to subtract by 2

You can use the /e switch of the substitution operator:
perl -pe 's/([0-9]{10})$/sprintf "%010d",$1-2/e'

Update: I am not sure how to search for the line, though, because you did not give any information on how these lines are structured. Adding that to the one-liner is easy, e.g. let's pretend we want to process lines beginning with 0TONY:

perl -pe 's/([0-9]{10})$/sprintf "%010d",$1-2/e if /^0TONY/'

Update 2: sprintf added. Thanks derby.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ