Re: recording the position of m// searches

2004-05-13 Thread Jeff 'japhy' Pinyan
On May 13, Tim & Kylie Duke said: >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 patt

RE: recording the position of m// searches

2004-05-13 Thread Tim Johnson
Two thoughts here: 1) The $. Variable has the line number of the file you are iterating through, so you could use that combined with pos() 2) You could also try something like this: while(){ if($_ =~ /.{20}$pattern.{20}/){ push(@found,$1); } } -Original Message- From: