@stuff = ('This is some text.','This is more text.'); $stext = '/some/i'; ($null, $text, $mod) = split(/\//, $stext); foreach (grep /$text/$mod, @stuff) { print $_, "\n"; }