I am reading a full file in a string and then am matching a regex below:
if ($ str = ~ m / $ regex / gc) {$ offset = $ + [0]; } Using this code, I can capture the situation where the last successful match ends.
Now this will give the status as the character number.
Is there a way that I can get the offset in line number? What I am doing now is that I start from the beginning of $ offset from the end of the number of new characters $ str / P> I want to know that Reggae is a direct way of capturing the line number for the match. The reason for this is that any string can read like files using Perl. Is:
Strictly use; Use warnings; My $ str = & lt; & Lt; EOS; Spam spam spam match spam match eos open my $ handle, '& lt;', \ $ str or die $!; While (& lt; $ handle & gt;) {print $., "\ N" if / match /; } OUTPUT 4 6
Comments
Post a Comment