package Regexp; use strict; use vars qw($file_re); my $underscore = '_'; my $non_dot = '[^.]'; my $dot = '[.]'; $file_re = qr/((nonconsolidated|other)$underscore)?(faq|organization|literature|contact|service)$underscore($non_dot+)${dot}xls/ ; 1; use Regexp; use strict; my @file = qw( Organization_DOT.xls.txt other_Service_FDNY.xls.txt nonconsolidated_FAQ_NYPD.xls.txt ); for (@file) { warn $_; if (/$Regexp::file_re/i) { warn "$1 $2 $3 $4"; warn $&; } else { warn 'AaaaaaaH'; } }