undef $/; my @text = split (//, <$FILE>); for (my $i = 0; $i <= $#text; $i++) { my $j = $i; if (($text[$i++] == 'h' || $text[$i++] == 'H') && $text[$i++] == 'e'...) { while ($j <= $i) { print $text[$j++]; } } }