Hi,

I am trying to build a perl program that reads through a very large text
file, searches for a pattern, and prints the pattern - within its context -
into a log file for later study.  The context is defined as, say, 20
characters before and after the found pattern.  I intend to use this for
linguistic analysis.

So I am thinking, use m//g to search, then push the found locations onto a
list, then come back, printing out parts of the text file based on the
search positions in the list, and use a context of 20 characters on either
side.

The pos() function within a m//g loop seems to return the position within
the line, not the position within the file.  Is there a different function
to return the absolute position in the file, which I could then use later on
as a basis for 
(very roughly)
    for each sort(@found_locations)
         print text from $position - 20 to $position +20

Thanks,

Tim



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to