If you are going to analyze character by character, you probably want the whole file in one string and to find just
the offset of your word. The first part is called slurping the file; one method is to set $/ to undef (see
perlvar), then read the file with <> or
readline; this will read the whole file. If you then match in scalar context using the g flag, the
pos of the string will be set to the end of your match. You can then examine nearby characters with
substr.
I'd provide an example, but it's not clear exactly what you
are going to do once you find a match.