#!/usr/bin/perl -w @numberarray = qw(00000900011 10001000100 00022200101); for $digits (@numberarray){ @temparray = split (//,$digits); $incr=0; while ($temparray[0] eq 0) { shift @temparray; $incr++; } unshift (@temparray," "x$incr); $digits = join('',@temparray); print "$digits\n"; }