Can a Perl program know the line number where __DATA__ begins? : <p>Is there a way to get the line number (and maybe filename) where a <strong>__DATA__</strong> token was coded?  Or some other way to know the actual line number in the original source file where a line of data read from the <em>DATA</em> filehandle came from?</p>

<p>Note that <code>$.</code> counts from 1 when reading from the <code>DATA</code> filehandle.  So if the line number of the <code>__DATA__</code> token were added to <code>$.</code> it would be what I'm looking for.</p>

<p>For example:</p>

<pre><code>#!/usr/bin/perl
while (&lt;DATA&gt;) {
  my $n = $. + WHAT??;
  die "Invalid data at line $n\n" if /bad/;
}

__DATA__
something good
something bad
</code></pre>

<p>I want this to say "Invalid data at line 9", not "line 2" (which is what you get if <code>$.</code> is used by itself).</p>
