in reply to How to create Nested packages?
You can't nest packages that way, packages don't nest.
But if you want to create a lexical variable seen by all three packages, just declare it:
perl -Mstrict -e "package PA; my $foo = 'hello'; package PB; use stric +t; print $foo;"
But creating "package global" lexicals is always a design flaw in my opinion, as you will sooner or later want to modify this variable from the outside. You will want to either provide a method to change your "global" or make it a real global variable.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to create Nested packages?
by Anonymous Monk on Jan 11, 2008 at 10:57 UTC | |
by Corion (Patriarch) on Jan 11, 2008 at 11:37 UTC | |
by memnoch (Scribe) on Jan 11, 2008 at 14:14 UTC |