#!/usr/bin/perl -w use strict; my @words = qw(COMA STORAMA HISTOROMA PUMA MELANOMA STOROMA); for my $str ( @words ) { if ($str =~ /OMA$/ and $str !~ /STOROMA$/ ) { print "$str\n"; } }