use strict; use warnings; my @aTemp = qw(Fred Betty Barney Wilma); @aTemp = grep{$_ =~ /B.*?y/} @aTemp; print join',',@aTemp;