Just another Perl shrine | |
PerlMonks |
Re: Add - in between number in a fileby FreeBeerReekingMonk (Deacon) |
on Jun 08, 2019 at 19:09 UTC ( [id://11101138]=note: print w/replies, xml ) | Need Help?? |
TIMTOWTDI. Used substr() and simple functions.
I have added an extra check, just in case it is a smaller number and not the 9 numbers, we put "0" in front of our read $line. but know that Perl handles the numbers in the files as strings, only when you start doing mathematical operations with them, then Perl automatically handles them as numbers. You can also just print a warning and skip, like so:
edit: added latter check. Assuming we have positive integer numbers only (no E or negative numbers, no floats)
In Section
Seekers of Perl Wisdom
|
|