in reply to Preserve working directory

It looks like an unnecessary obfuscation. How about this instead...
package PreserveWD; use strict; use Cwd qw(cwd); sub new { my $class = shift; my $self = cwd; bless \$self, $class; } sub DESTROY { chdir ${+shift) or die "Cannot restore directory\n"; }
I think this is the model that SelectSaver uses. Yup. Similar code.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re^2: Preserve working directory
by Aristotle (Chancellor) on Dec 18, 2002 at 15:33 UTC
    my $class = shit;
    Actually, your class is nice. :^) (Yes, I know I'm a bit late to the party. This was just too good to pass up anyway.)

    Makeshifts last the longest.