use strict;
my $str = 'overdraft-transactions_2020-06-19_10_20200620020000.csv
overdraft-transactions_2020-06-19_10_20200620020000.csv.sha1
overdraft-transactions_2020-06-20_6_20200621020000.csv
overdraft-transactions_2020-06-20_6_20200621020000.csv.sha1
overdraft-transactions_2020-06-21_6_20200622020000.csv
overdraft-transactions_2020-06-21_6_20200622020000.csv.sha1
overdraft-transactions_2020-06-22_7_20200623020000.csv
overdraft-transactions_2020-06-22_7_20200623020000.csv.sha1
overdraft-transactions_2020-06-23_6_20200624020001.csv
overdraft-transactions_2020-06-23_6_20200624020001.csv.sha1
overdraft-application_2020-06-19_0_20200620020000.csv
overdraft-application_2020-06-19_0_20200620020000.csv.sha1
overdraft-application_2020-06-20_0_20200621020000.csv
overdraft-application_2020-06-20_0_20200621020000.csv.sha1
overdraft-application_2020-06-21_0_20200622020000.csv
overdraft-application_2020-06-21_0_20200622020000.csv.sha1
overdraft-application_2020-06-22_0_20200623020000.csv
overdraft-application_2020-06-22_0_20200623020000.csv.sha1
overdraft-application_2020-06-23_0_20200624020001.csv
overdraft-application_2020-06-23_0_20200624020001.csv.sha1
overdraftlog-20201005122521.748.log
overdraftlog-20201005122521.748.log.sha
overdraftlog-20201006030000.749.log
overdraftlog-20201006030000.749.log.sha';
my $regex = qr/overdraftlog-[0-9]{14}.[0-9]{3}(.log$|.log.sha$)/mp;
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