Cwd::Guard(3pm)

Cwd::Guard3pm

Temporary changing working directory (chdir)

Usage

  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

Overview

CORE::chdir Cwd:: Guard can change the current directory (chdir) using a limited scope.

Functions

cwd_guard($dir);

chdir to $dir and returns Cwd::Guard object. return to current working directory, if this object destroyed. if failed to chdir, cwd_guard return undefined value. You can get error messages with $Gwd::Guard::Error.

Releases

7 releases since Debian 8 (Jessie); the text changed 3 times.

  1. 8
  2. 9–11
  3. 12–13
  4. Arch

Author

Masahiro Nagano <kazeburo {at} gmail.com>

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.

From perl-cwd-guard 0.05-13 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.