Path::This - Path to this source file or directory
use Path::This '$THISFILE'; print "This file is $THISFILE\n"; use Path::This '$THISDIR'; use lib "$THISDIR/../lib";
Exports package variables by request that represent the current source file or directory containing that file. Dynamic or constant sub versions can also be requested. Paths will be absolute with symlinks resolved.
Note that the package variable or constant sub will be exported to the current package globally. If the same package will be used in multiple files, use the dynamic sub export so the file path will be calculated when the sub is called.
print "$THISFILE\n"; my $file = THISFILE;
Absolute path to the current source file. Behavior is undefined when called without a source file (e.g. from the command line or STDIN). $THISFILE will export a package variable, &THISFILE will export a dynamic subroutine, and THISFILE will export an inlinable constant.
$THISFILE
&THISFILE
THISFILE
print "$THISDIR\n"; my $dir = THISDIR;
Absolute path to the directory containing the current source file, or the current working directory when called without a source file (e.g. from the command line or STDIN). $THISDIR will export a package variable, &THISDIR will export a dynamic subroutine, and THISDIR will export an inlinable constant.
$THISDIR
&THISDIR
THISDIR
Report any issues on the public bugtracker.
Dan Book <dbook@cpan.org>
This software is Copyright (c) 2019 by Dan Book.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)
FindBin, Dir::Self, lib::relative
To install Path::This, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Path::This
CPAN shell
perl -MCPAN -e shell install Path::This
For more information on module installation, please visit the detailed CPAN module installation guide.