Cwd::Guard(3pm)
π Cwd::Guard(3pm) π
okay so bestie, this is the manual page for Cwd::Guard, and it's literally about temporary changing working directory (chdir). No cap. β¨
πΈ NAME πΈ
Cwd::Guard β Temporary changing working directory (chdir). π¦
β¨ SYNOPSIS β¨
Here's the vibe in code, bestie:
use Cwd::Guard qw/cwd_guard/;
use Cwd;
my $dir = getcwd;
MYBLOCK: {
my $guard = cwd_guard('/tmp/xxxxx') or die "failed chdir: $Cwd::Guard::Error";
# chdir to /tmp/xxxxx
}
# back to $dir
π¦ DESCRIPTION π¦
CORE::chdir? okay so Cwd::Guard can change the current directory (chdir) using a limited scope. It's giving scoped chdir energy, and honestly? Iconic. π
π FUNCTIONS π
π«Ά cwd_guard($dir);
This is the main character function, fr fr. It does chdir to $dir and returns a Cwd::Guard object. When this object gets destroyed, it returns to the current working directory. the way that scope just cleans up after itself, periodt. π
If chdir fails, cwd_guard returns an undefined value. You can get error messages with $Gwd::Guard::Error. yes bestie, that's exactly how it's spelled in the docs β keep it. And in the synopsis you'll see $Cwd::Guard::Error inside the die string, so both are living here, no cap. π
π AUTHOR π
Masahiro Nagano <kazeburo {at} gmail.com> β absolute legend. π«Ά
π SEE ALSO π
File::chdirFile::pushd
π LICENSE π
Copyright (C) Masahiro Nagano
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
mwah π β this page comes from perl v5.42.2, dated 2023-07-03, bestie. periodt. β¨π
π¦ where this page comes from
- alpine 3.24: perl-cwd-guard-doc 0.05-r1 Β· 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