my @words = qw[ new old number start simple cross heavy die exit ]; my $string = q~whatever the NEw old you're trying to match~; my $lcstring = lc $string; my $ret = 0; if( do { for my $val( @words ){ my $r = index $lcstring, $val; if( $r > -1 ){ $ret = substr $string, $r, length $val; last; } } $ret; } ){ warn "the \$1 (aka ret) is => $ret\n\n"; } __END__ the $1 (aka ret) is => NEw