use strict;
my $str = 'qwarebatch_nc_20140714.TXT
AF32503.txt
CV4130214.TXT
CA5070515.TXT
CD4130115.txt
CC4130214.TXT
DI41102.txt
qwarebatch_dar_20150602.TXT
qwarebatch_darf_20150602.TXT
DC4130214.TXT
DL4160214.TXT
EC5070515.TXT
GF41102.txt
GP41102.TXT
qwarebatch_gru_intra_20150602.TXT
qwarebatch_lc_20150602.TXT
LO4130214.TXT
NT32503.txt
qwarebatch_nd_20150602.TXT
qwarebatch_ne_20150602.TXT
qwarebatch_nl_20150602.TXT
qwarebatch_ns_20150602.TXT
qwarebatch_ob_20150602.TXT
qwarebatch_pe_20140618.TXT
qwarebatch_pf_20150602.TXT
qwarebatch2_ptres_20150602.TXT
qwarebatch_ra_20150602.TXT';
my $regex = qr/^((qwarebatch[0-9]?_((g?p(tres|[fse])|lc|ra|darf?|n[edlcs]|ob|gru_intra))_)|([AG]F|[EL]?[CO]([ACDV])?|D[CIL]|NT))[0-9]{5,8}\.TXT.*/imp;
if ( $str =~ /$regex/g ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html