in reply to Packages symbol tables and namespaces:
require 'newPackage.pl'; #exporting the package namespace
What require does is not exporting something, but opening your script, and running it again - which is why you get output twice.
I'd write that as
use strict; use warnings; { #creating a package package newPackage; sub subroutine1 { print "*This is a new package called from within the file*\n"; } } print keys(%newPackage::),"\n"; print "\n\n";
Also you should load packages with use, and exporting is done with Exporter.
|
|---|