use v5.12; use warnings; my $Namelist = 'Wilma Fred Barney Betty Dino'; if ( $Namelist =~ m/(\w+a)/ ) { print "Matched|$<$&$>|\n"; say "The name that matched was $1 \n"; } else { print "No match: \n"; } #### Matched|0Wilma0| The name that matched was Wilma #### Matched|| The name that matched was Wilma #### Matched|$$| The name that matched was Wilma #### Matched|Wilma| The name that matched was Wilma #### Matched|###Wilma###| The name that matched was Wilma