Jim,

You could start by defining what a word is, using some regex:

$wordRegex = qr/... something here .../;

Then build up from there:

($match) = $input =~ /($wordRegex{10}\s$word\s$wordRegex{10})/;

Just an idea.

--------------------------
David Olbersen 
iGuard Engineer
11415 West Bernardo Court 
San Diego, CA 92127 
1-858-676-2277 x2152


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, April 02, 2003 11:42 AM
> To: [EMAIL PROTECTED]
> Subject: Retrieving word and sourounding text
> 
> 
> 
> $word = "seminary";
> 
> 
> I am trying to retrieve a word, and the surrounding text in a 
> file. For 
> example, read through a file for $word, and when matched, 
> place in a variable 
> the matching word, along with the 10 words preceding it and 
> trailing it, and 
> have it work over multiple lines. Is there an effective way 
> to do this in 
> Perl?  i.e., in the paragraph above, if I searched for the 
> word "along" match 
> would contain what is written below. Can anyone help me with 
> this? Thanks.
> 
> $match = "and when matched, place in a variable the matching 
> word, along with 
> the 10 words preceding it and trailing it, and";
> 
> 
> 
> 
> 
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to