dirtdog has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, I'm hoping someone can assist with a one-liner. I'm trying to pad a leading zero to a 5 digit time. I'm close, but I'm missing something.
perl -i.bak -pe 's/\<time\>(\d+)\<\/time\>/\<time\>sprintf("%06d",$1)\ +<\/time\>/ if /\<time\>(\d{5})\<\/time\>/' <file>
I'm ending up with the following:
<time>sprintf("%06d",10001)</time>
and I'm expecting this:
<time>010001</time>
any help would be greatly appreciated!
Back to
Seekers of Perl Wisdom