my $test = "2523"; $test = "0" . $test if($test=~/^\d{4}$/); print "$test\n";