Acme-CPANLists-PERLANCAR
view release on metacpan or search on metacpan
lib/Acme/CPANLists/PERLANCAR/MagicVariableTechnique.pm view on Meta::CPAN
our $DATE = '2017-09-08'; # DATE
our $VERSION = '0.26'; # VERSION
our @Module_Lists = (
{
summary => 'Modules which employ magic variable technique to do stuffs',
description => <<'_',
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()`.
_
entries => [
{
module => 'File::chdir',
description => <<'_',
Provides `$CWD` which you can use to change directory. By doing:
local $CWD = ...;
lib/Acme/CPANLists/PERLANCAR/MagicVariableTechnique.pm view on Meta::CPAN
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.
_
},
{
module => 'File::umask',
description => <<'_',
Provides `$UMASK` to get/set umask.
_
},
{
module => 'Umask::Local',
description => <<'_',
Like <pm: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.
_
alternate_modules => ['File::umask'],
},
{
module => 'Locale::Tie',
description => <<'_',
Provides `$LANG`, `$LC_ALL`, `$LC_TIME`, and few others to let you (temporarily)
set locale settings.
_
},
{
module => 'Locale::Scope',
description => <<'_',
Like <pm:Locale::Tie>, but instead of using a tied variable, uses an object with
its `DESTROY` method restoring original settings.
_
},
],
},
);
1;
# ABSTRACT: Modules which employ magic variable technique to do stuffs
lib/Acme/CPANLists/PERLANCAR/MagicVariableTechnique.pm view on Meta::CPAN
=head1 VERSION
This document describes version 0.26 of Acme::CPANLists::PERLANCAR::MagicVariableTechnique (from Perl distribution Acme-CPANLists-PERLANCAR), released on 2017-09-08.
=head1 MODULE LISTS
=head2 Modules which employ magic variable technique to do stuffs
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 C<local()>.
=over
=item * L<File::chdir>
Provides C<$CWD> which you can use to change directory. By doing:
local $CWD = ...;
lib/Acme/CPANLists/PERLANCAR/MagicVariableTechnique.pm view on Meta::CPAN
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.
=item * L<File::umask>
Provides C<$UMASK> to get/set umask.
=item * L<Umask::Local>
Like L<File::umask>, but instead of using a tied variable, uses an object with
its C<DESTROY> method restoring original umask. I find the interface a bit more
awkward.
Alternate modules: L<File::umask>
=item * L<Locale::Tie>
Provides C<$LANG>, C<$LC_ALL>, C<$LC_TIME>, and few others to let you (temporarily)
set locale settings.
=item * L<Locale::Scope>
Like L<Locale::Tie>, but instead of using a tied variable, uses an object with
its C<DESTROY> method restoring original settings.
=back
=head1 HOMEPAGE
Please visit the project's homepage at L<https://metacpan.org/release/Acme-CPANLists-PERLANCAR>.
=head1 SOURCE
lib/Acme/CPANLists/PERLANCAR/Task/GettingTempDir.pm view on Meta::CPAN
{
summary => 'Getting system-wide temporary directory in a portable way',
description => <<'_',
There's the good ol' <pm:File::Spec> which has a `tmpdir` function. On Unix it
looks at `TMPDIR` environment variable before falling back to `/tmp`.
<pm:File::Temp> uses this for its `tempdir` when a template is not specified.
Then there's <pm:File::Util::Tempdir> which tries a little harder. On Unix, its
`get_tempdir` will look at `TMPDIR`, then also `TEMPDIR`, `TMP`, `TEMP`. If none
of those are set, it will return the first existing directory from the list:
`/tmp`, `/var/tmp`. If everything fails, will die.
_
tags => ['task'],
entries => [
{
module=>'File::Spec',
},
{
module=>'File::Util::Tempdir',
lib/Acme/CPANLists/PERLANCAR/Task/GettingTempDir.pm view on Meta::CPAN
=head1 MODULE LISTS
=head2 Getting system-wide temporary directory in a portable way
There's the good ol' L<File::Spec> which has a C<tmpdir> function. On Unix it
looks at C<TMPDIR> environment variable before falling back to C</tmp>.
L<File::Temp> uses this for its C<tempdir> when a template is not specified.
Then there's L<File::Util::Tempdir> which tries a little harder. On Unix, its
C<get_tempdir> will look at C<TMPDIR>, then also C<TEMPDIR>, C<TMP>, C<TEMP>. If none
of those are set, it will return the first existing directory from the list:
C</tmp>, C</var/tmp>. If everything fails, will die.
=over
=item * L<File::Spec>
=item * L<File::Util::Tempdir>
=back
( run in 0.522 second using v1.01-cache-2.11-cpan-49f99fa48dc )