in reply to Fill an array in a module ?
Variables in a module can be exported (see Exporter) or they can be accessed from outside the module using their fully qualified name:
package MyModule; our @SharedArray = (1, 2, 3, 4); # shared my @PrivateArray = (5, 6, 7, 8); # not shared 1;
use MyModule; print MyModule::SharedArray[1]; # prints 2
In Perl, each module has its own namespace. This allows developers of modules and programs to name variables and functions without worrying about the names in programs or other modules.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Fill an array in a module ?
by AnomalousMonk (Archbishop) on Sep 14, 2014 at 01:20 UTC | |
by Anonymous Monk on Sep 14, 2014 at 05:18 UTC | |
by dsheroh (Monsignor) on Sep 14, 2014 at 07:59 UTC | |
by RonW (Parson) on Sep 15, 2014 at 16:39 UTC | |
by DarrenSol (Acolyte) on Sep 17, 2014 at 17:15 UTC | |
|
Re^2: Fill an array in a module ?
by DarrenSol (Acolyte) on Sep 17, 2014 at 17:06 UTC | |
by RonW (Parson) on Sep 17, 2014 at 17:34 UTC |