Created
October 22, 2012 17:02
-
-
Save sashaphanes/3932577 to your computer and use it in GitHub Desktop.
add zeroes to the front
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -s | |
#Q19. Write a simple perl statement to add leading 0s for the integers which is less than 10000. | |
#Assume the integers are in the range of 1 to 9999. | |
while (<>) { | |
$_ =~ s/([0-9]+)/sprintf('%05d',$1)/ge; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment