Acme::CPANLists::PERLANCAR::MagicVariableTechnique - Modules which employ magic variable technique to do stuffs
This document describes version 0.26 of Acme::CPANLists::PERLANCAR::MagicVariableTechnique (from Perl distribution Acme-CPANLists-PERLANCAR), released on 2017-09-08.
This is a list of modules which provide some "magic" variable which you can get/set to perform stuffs. I personally find this technique is mostly useful to "temporarily set" stuffs, by combining it with Perl's local().
local()
File::chdir
Provides $CWD which you can use to change directory. By doing:
$CWD
local $CWD = ...;
in a subroutine or block, you can safely change directory temporarily without messing current directory and breaking code in other parts. Very handy and convenient.
This is the first module I found/use where I realized the technique. Since then I've been looking for other modules using similar technique, and have even created a few myself.
File::umask
Provides $UMASK to get/set umask.
$UMASK
Umask::Local
Like File::umask, but instead of using a tied variable, uses an object with its DESTROY method restoring original umask. I find the interface a bit more awkward.
DESTROY
Alternate modules: File::umask
Locale::Tie
Provides $LANG, $LC_ALL, $LC_TIME, and few others to let you (temporarily) set locale settings.
$LANG
$LC_ALL
$LC_TIME
Locale::Scope
Like Locale::Tie, but instead of using a tied variable, uses an object with its DESTROY method restoring original settings.
Please visit the project's homepage at https://metacpan.org/release/Acme-CPANLists-PERLANCAR.
Source repository is at https://github.com/perlancar/perl-Acme-CPANLists-PERLANCAR.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Acme-CPANLists-PERLANCAR
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Acme::CPANLists - about the Acme::CPANLists namespace
acme-cpanlists - CLI tool to let you browse/view the lists
perlancar <perlancar@cpan.org>
This software is copyright (c) 2017, 2016, 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Acme::CPANLists::PERLANCAR, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Acme::CPANLists::PERLANCAR
CPAN shell
perl -MCPAN -e shell install Acme::CPANLists::PERLANCAR
For more information on module installation, please visit the detailed CPAN module installation guide.