Wednesday, May 1, 2019

Perl - get the script path

# C:\Foo\Bar\my_script.pl

use strict;
use warnings;

use FindBin qw($Bin);

print "My script lives in $Bin\n"; # My script lives in C:/Foo/Bar


Note that there is no trailing slash, and Windows back-slashes '\' are converted to forward slashes '/'