Skip to content

Instantly share code, notes, and snippets.

@sashaphanes
Created October 22, 2012 17:02
Show Gist options
  • Save sashaphanes/3932577 to your computer and use it in GitHub Desktop.
Save sashaphanes/3932577 to your computer and use it in GitHub Desktop.
add zeroes to the front
#!/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