while (<>) { my $istr = lc($_); my $offset = index($istr,"cesi"); print $offset."\n"; if ($offset > -1) { my $str = substr($istr, $offset-20, 100); print $str."\n"; } }