use strict; my $if = 1; my @list= ("a".."c","DBIC","A".."C","DANCER","a".."c"); my @result; for (@list) { if( $if ) { # Comment this out push @result,$_ if /DBIC/.. /DANCER/ and ! //; } # Comment this out } print $_, $/ for @result; __END__