in reply to Re: local() peculiarities
in thread local() peculiarities

Nice. Works. How do I cancel it? "no vars qw(blabla)" or even "no vars" doesn't do it. See:

@jea=([1,"one"],[2,"two"],[3,"three"],); huu(\@jea); sub huu { my $i; for $i (0 .. $#{$_[0]}) { if ($_[0][$i]) { use vars (@bla); local *bla=$_[0][$i]; print "$i: @bla\n"; } print "@bla\n"; } }

As you can see, the later reference to "@bla" is still affected by "use vars" in above block; it doesn't give the warning/error it should. I thought the pragma should expire at the end of block (some doc implied that), but no...

-Kaatunut

Replies are listed 'Best First'.
Re: Re: Re: local() peculiarities
by chipmunk (Parson) on Jan 22, 2001 at 23:03 UTC
    I thought that was weird too, so I looked it up. It turns out that, unlike most pragmas, vars is not block scoped.

    Here's the snippet:

    Unlike pragmas that affect the $^H hints variable, the use vars and use subs declarations are not BLOCK-scoped. They are thus effective for the entire file in which they appear. You may not rescind such declarations with no vars or no subs.