use Date::Calc qw(Add_Delta_Days); my $input = "11004"; # yyddd $input =~ /(\d\d)(\d\d\d)/; my ($y, $m, $d) = Add_Delta_Days("20$1",1,1, $2 -1); # based on an example in the Date::Calc-docu my $output = sprintf("%4d%02d%02d", $y, $m, $d);