in reply to Using an "outer" lexical in a sub?

$n1 is simply a global. It is global to everything (including subroutines and nested blocks) from the point where it is declared onward.

Actually no language I can think of (of the small number I've used) hides global variables from subroutines/functions/class members. Is there a bigger picture here that is leading to your confusion?

Update: Fletch is quite right that I'm playing fast and loose with nomenclature here. C's 'file scope' is the notion I intended by "global". My appologies for any confusion caused.


DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Using an "outer" lexical in a sub?
by Fletch (Bishop) on Nov 01, 2006 at 20:42 UTC

    It's a lexical at the outermost scope (what'd probably be referred to as "file scope" in C-land) and it's visibility is limited to everything lexically within the file it's declared in (after the point at which the declaration occurs, of course).

    I think you're getting --'d here because calling a file scope'd lexical a "global", the term usually in Perl usage referring to package variables which live in the truly global symbol table, is only likely to further confuzzle people.

    Update: Someone else below has them called "file statics" in C; I've heard both terms I think.