Yet Another Way to capture first matching file, if any, and number of matching files concisely:
c:\@Work\Perl\monks>perl -wMstrict -le
"my @files = qw(xxx 1st_CF_xx CF__ 2nd_CF_yy CF);
;;
my $n_CF_ = my ($first_CF_) = grep /_CF_/, @files;
;;
print qq{number of _CF_ files: $n_CF_};
if ($n_CF_ == 1) { print qq{just one: '$first_CF_'}; }
"
number of _CF_ files: 2
c:\@Work\Perl\monks>perl -wMstrict -le
"my @files = qw(xxx 1st_CF_xx CF__ CF);
;;
my $n_CF_ = my ($first_CF_) = grep /_CF_/, @files;
;;
print qq{number of _CF_ files: $n_CF_};
if ($n_CF_ == 1) { print qq{just one: '$first_CF_'}; }
"
number of _CF_ files: 1
just one: '1st_CF_xx'
c:\@Work\Perl\monks>perl -wMstrict -le
"my @files = qw(xxx yyy zzz);
;;
my $n_CF_ = my ($first_CF_) = grep /_CF_/, @files;
;;
print qq{number of _CF_ files: $n_CF_};
if ($n_CF_ == 1) { print qq{just one: '$first_CF_'}; }
"
number of _CF_ files: 0
Update: Be aware that if no files match the grep condition in the example code above, $first_CF_ is undefined.
Give a man a fish: <%-{-{-{-<