On Wed, Dec 10, 2003 at 09:58:14PM -0500, Ron Newman wrote:
> 
> On Dec 10, 2003, at 9:39 PM, Ron Newman wrote:
> 
> >If I slurp a file into a string variable (either Uri's way or my own 
> >way), and then do a regexp match, I'd like to determine the line 
> >number(s) of the match.    Is there a straightforward or canonical way 
> >to do this?
> 
> I've already gotten one private reply of "don't slurp the file".  To 
> head off any more, I should add that my regexp match may span multiple 
> lines.

You could count newlines after doing the match, maybe something like:

substr($_, 0, $-[0]) =~ tr/\n// + 1;

$-[0] is the offset of the start of the match.


But I think the best way really depends on what else you're doing with the
string.

Ronald
_______________________________________________
Boston-pm mailing list
[EMAIL PROTECTED]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to