... if( $csv_line =~ /([A-Z])\s+([A-Z])(?:\s+\d\.\d{3}){3}/ ) { ... } elsif( $csv_line =~ /^SEQ.+/ ) { ... } else { # What do you do with a line that matches neither pattern? } ...