title: How to get the current line number of a file opened using Perl
body: <pre><code>open my $fp, '&lt;', $file or die $!;
  
  while (&lt;$fp&gt;) {
      my $line = $_;
      if ($line =~ /$regex/) {
          # How do I find out which line number this match happened at?
      }
  }
  
  close $fp;
  </code></pre>