in reply to local() peculiarities

local is primarily a run-time operation, but the warning you're getting is a compile time warning. And yes, there's been no specific use of @array down to the interpolation, so the compiler is rightly whining. I think you can add this to get things clean again:
use vars qw(@array);
Because that promises that there will be a symbol named @array at runtime, and therefore I can call it without a package.

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: Re: local() peculiarities
by kaatunut (Scribe) on Jan 22, 2001 at 22:55 UTC
    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

      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.