paurus has asked for the wisdom of the Perl Monks concerning the following question:
Is it possible to use the $. variable as a definitive start and end for a range of text extraction? If so, how can I go about implementing this for my line number range? Thank you. -pauruswhile(<F>) { if(/\bREGEXP\b/) { $seen++; push(@lines, $.); print "\nMatch found:\n\n\tFILENAME: $dir/$file\n\tLINE: $. : '$`~$& +~$'"; if(($.) .. ($. + 3) { print; } # my range extract code # OR print "$`$&$'\n" if(($.)..($. + 3)); # my range extract code }else { next; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Line(s) extraction
by BrowserUk (Patriarch) on Apr 01, 2004 at 06:55 UTC | |
|
Re: Line(s) extraction
by kvale (Monsignor) on Apr 01, 2004 at 06:56 UTC |