NAME
Path::This - Path to this source file or directory
SYNOPSIS
use Path::This '$THISFILE';
print "This file is $THISFILE\n";
use Path::This '$THISDIR';
use lib "$THISDIR/../lib";
DESCRIPTION
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.
EXPORTS
$THISFILE
&THISFILE
THISFILE
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.
$THISDIR
&THISDIR
THISDIR
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.
BUGS
Report any issues on the public bugtracker.
AUTHOR
Dan Book <dbook@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2019 by Dan Book.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)