develooper Front page | perl.perl5.porters | Postings from September 2001

Re: [PATCH op.c op.h pp_sys.c t/op/local.t pod/perlfunc.pod] local chdir()

Thread Previous | Thread Next
From:
Michael G Schwern
Date:
September 1, 2001 12:35
Subject:
Re: [PATCH op.c op.h pp_sys.c t/op/local.t pod/perlfunc.pod] local chdir()
Message ID:
20010901153541.P606@blackrider
On Sat, Sep 01, 2001 at 02:26:36PM -0400, Bryan C. Warnock wrote:
> > Because, you have the weird caveat of having to keep the returned
> > variable around.
> >
> >     use File::chdir;
> >
> >     {
> >         my $old_dir = chdir($dir);
> >     }
> >
> > The wires are showing through the magician's trick.
> 
> Wouldn't that be:
> 
> use File::chdir;
> 
> {
>     local $cwd = $dir;     # Assuming $cwd FETCH and STORE manipulated chdir
> }

I didn't want to introduce a completely different way to change the
directory.

But let's say I did.  How does a tied variable know it's been
localized?

    $CWD = "bar";

    {
        local $CWD = "foo";
    }

seems to trigger...

    $tied_obj->STORE("bar");

for the first assignment.

    $tied_obj->FETCH
    $tied_obj->STORE
    $tied_obj->STORE("foo");

from the local and

    $tied_obj->STORE(1)

when it falls out of scope.

It *looks* like it's trying to reset the original value via that last
STORE, but screwing it up.


> Also, one comment on your patch - I saw a doc change for chdir, but I didn't 
> see one for local.

There's one in there.


-- 

Michael G. Schwern   <schwern@pobox.com>    http://www.pobox.com/~schwern/
Perl6 Quality Assurance     <perl-qa@perl.org>	     Kwalitee Is Job One
Some like elmers glue
but it needs reapplying.
I use super glue.
	-- tlk

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About