my @dates = ( '1010', '1007'); foreach my $date (@dates) { my ($year,$mon) = $date =~ m/\d\d/g; print "year = $year month= $mon\n"; }