borisz meant the first group of four digits, which is perfect if you can count on the data format.
Why not do your loop all in one line?
my @years = map /(\d{4})/, @dates;
Of course, you could use any regex that satisfies in the code above. Note that the parenthesis are critical, without them you'll wind up with a list full of '1'.
Update Thanks to Roy Johnson I fixed my regex. Left out the \ for the \d.
|