Yes, I think I'm clear on this; at least I hope so after banging my head
against Programming Perl 3.  Globals are dynamically-scoped whereis lexicals
only exist in the file where they are declared with my.  Page 57 says:

"Because the file is the largest possible lexical scope, a lexically-scoped
variable can never be visible outside the file in which it's declared. File
scopes do not nest".

So what I was thinking of doing was something like:

my ($a,$b);

# main code
...

#include "subs1.pl"
...

where code in subs1.pl made reference to $a and $b.  I realize that I can do
this with globals.  So that's what I'll do.

"Michael Fowler" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Thu, Sep 19, 2002 at 10:33:05AM -0000, Cricker wrote:
> > If I may summarize -- and please correct me if this is wrong -- there is
> > indeed no way to textually include one file inside another, like
#include
> > in C.
>
> As I mentioned previously in this thread, C is able to share its variables
> between include files because they are global variables.  In this sense,
> Perl can do the same thing with use or require as C does with include.
>
>
> > The text file is the compilation (lexical) unit, and the only way to
> > import lexical symbols is via the module (package) mechanism.
>
> The file is indeed a new lexical scope.  However, you cannot import or
> export lexically-scoped variables (symbols isn't the appropriate term in
> this context).  You can only import and export package globals.
>
> I'm sensing some confusion between lexical and global variables.  Are you
> certain what the differences are?
>
>
> Michael
> --
> Administrator                      www.shoebox.net
> Programmer, System Administrator   www.gallanttech.com
> --



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to