perl -pi.bak -e 's/^/sprintf( "%05d", $.).": "/e' test.pl #### perl -pi.bak -e 's/^(?:\s+)?\d+:\s//' test.pl