in reply to local scoped cwd

in summary:
use Cwd; sub TIESCALAR {bless {} => shift} sub FETCH {cwd} sub STORE {defined $_[1] and (chdir $_[1] or die $!)} our $cwd; tie $cwd => __PACKAGE__;
that defined $_[1] is necessary becuase local seems to undef the variable at some point (otherwise resulting in a chdir to $HOME).

Replies are listed 'Best First'.
Re: Re: local scoped cwd
by bikeNomad (Priest) on Jun 28, 2001 at 05:31 UTC
    If you aren't going to use the blessed var, why bother with the overhead and size of a hash? Why not:
    sub TIESCALAR {bless \(my $dummy) => shift}

      I guess I was just playing golf. :)

      How well would { bless \$_ => shift } work?