sub left_pad { my($num, $len) = @_; do { $num = '0' . $num } while length($num) < $len; return $num; }