while ($line_data =~ /(?P(2004|04)(?P..)(?P..)(?P..)(?P.*?)1003..)/g) { print $+{A}; print $+{B}; print $+{C}; print $+{D}; }