in reply to Getting the line numbers of a multi-line match
$-[0]
Simple approach:
my $line_num = 1 + ( () = substr($text, 0, $-[0]) =~ /\n/g ); [download]