I considered this, but I'd have to return the original working directory at the sub, since other subs assume that the working dir hasn't changed.
I suppose I could save the original working dir with
$prevdir = `pwd`;
But executing the shell command doesn't seem like it would be much more efficient than mapping the directory name on to each glob and then chopping it off... | [reply] [d/l] |
Use Cwd. It's a standard module.
use Cwd;
my $dir = cwd();
chdir $otherdir;
# do something
chdir $dir;
| [reply] [d/l] |