use strict; use warnings; #### use Modern::Perl; #### use Modern::Perl; my $word = 'a'; my @myNames = qw(Jacob Michael Joshua Matthew Alexander Andrew); if ( $word ~~ @myNames ) { # Using Perl's smart-matching operator say qq|Exact match of "$word" found.|; } elsif ( my @found = grep /\Q$word\E/i, @myNames ) { local $" = "\n"; # Printed between interpolated array's elements say qq|Substring/case-insensitive matches for "$word":\n@found|; } else { say qq|"$word" not found.|; } #### Substring/case-insensitive matches for "a": Jacob Michael Joshua Matthew Alexander Andrew