title: How do I get the name of the currently-running Perl script?
body: <p>I have a script</p>
  <pre><code>#!/usr/bin/env perl
  
  use strict;
  use warnings FATAL =&gt; 'all';
  use feature 'say';
  use autodie ':default';
  use mwe 'tmp';
  
  tmp();
  </code></pre>
  <p>that calls a Perl module <code>mwe</code></p>
  <pre><code>use feature 'say';
  package mwe;
  use Cwd 'getcwd';
  use Exporter qw(import);
  our @EXPORT = qw(tmp);
  
  sub tmp {
      say 'written by ' . getcwd() . '/' . __FILE__;
  }
  1;
  </code></pre>
  <p>but when I run this script, the filename appears from the module:</p>
  <pre><code>con@V:~/Scripts$ perl mwe.pl
  written by /home/con/Scripts//home/con/perl5/perlbrew/perls/perl-5.34.0/lib/5.34.0/mwe.pm
  </code></pre>
  <p>I'm still new at writing modules, so criticism there is appreciated, if my minimal working example isn't well-written.</p>
  <p>My question:
  I'm aware that I could pass the file <code>/home/con/Scripts/mwe.pl</code> as a parameter to the subroutine <code>tmp</code>, but is there a way that I could get a subroutine like <code>tmp</code> to return the script filename instead automatically?</p>