#!/usr/bin/perl -wl use strict; my @numberarray = qw(1 120 13); lengthy(@numberarray); sub lengthy { s{ ( ^ ) } { ( "0" x (6-length $_) ) }xe and print for @_; } __END__