There's nothing wretchedly wrong with your code that I can see. One this that might make it prettier (and a bit more intuitive) is to park your padding logic in a sub/function similar to the following:
use strict; while (<DATA>) { chomp; print padded($_), "\n"; } sub padded { #left-pads enough zeros to a number to ensure that there are at leas +t #four digits my ($num) = @_; my $padded = '0' x (4 - length($num)); return $padded . $num; } __DATA__ 23 102 2003 9
I am now going to make the obligatory statements about using the -w flag and use strict. There.
In reply to Re: Got's to be a better way
by Art_XIV
in thread Got's to be a better way
by ear
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |