Dir::Self(3)
πΈ NAME πΈ
Dir::Self β a __DIR__ constant for the directory your source file is in.
Okay bestie, welcome to the Dir::Self(3) page β User Contributed Perl Documentation edition, periodt. This is the module that gives your Perl source a little main character moment by knowing where it lives. π
β¨ SYNOPSIS β¨
Copy this exactly, iykyk:
use Dir::Self;
use lib __DIR__ . "/lib";
my $conffile = __DIR__ . "/config";
π DESCRIPTION π
Perl has two pseudo-constants describing the current location in your source code, __FILE__ and __LINE__. This module adds __DIR__, which expands to the directory your source file is in, as an absolute pathname. Slay. β¨
This is useful if your code wants to access files in the same directory, like helper modules or configuration data. Itβs a bit like FindBin, except itβs not limited to the main program, i.e. you can also use it in modules. And it actually works. π
As of version 0.10, each use of __DIR__ recomputes the directory name; this ensures that files in different directories that share the same package name get correct results. If you donβt want this, use Dir::Self qw(:static) will create a true __DIR__ constant in your package that contains the directory name at the point of use. Iconic, honestly. π
π«Ά AUTHOR π«Ά
Lukas Mai <l.mai @web.de>
π COPYRIGHT AND LICENSE π
Copyright (C) 2007, 2008, 2013 by Lukas Mai
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
Signing off from perl v5.42.2 on 2023-11-29 β stay iconic, bestie ππ¦π
π¦ where this page comes from
- alpine 3.24: perl-dir-self-doc 0.11-r4 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms