#!/usr/bin/perl # http://perlmonks.org/?node_id=1176603 use strict; use warnings; my @extract = grep /^[^sh]*s[^sh]*h[^sh]*$/i, map tr/\n//dr, ; print "@extract\n"; __DATA__ school schools hosepipes