Although it concerns PHP, the site https://www.sitepoint.com/php-server-api-differences/ has some good description of how web server configurations might vary – some include certain environment variables (specifically this one) while others do not. Some define SCRIPT_FILENAME as the name of the CGI script. Therefore, as our friend Anonymous Monk has already suggested, let Perl itself tell you the name of the script that it is now executing. This should be bulletproof.
I have also seen “trampoline” code that was intended to facilitate running (very) old code in new environments, which set certain environment-variable values that the hoary old legacy code was expecting before passing-off control to the old software.