http://www.perlmonks.org?node_id=939704


in reply to Code in package hell, deceive by debugger

use base::Vars qw(%runSwitches); # use vars qw(%runSwitches);

- tye        

Replies are listed 'Best First'.
Re^2: Code in package hell, deceive by debugger (T,IFI)
by throop (Chaplain) on Nov 30, 2011 at 15:46 UTC
    Thanks... but when I do that, I get fatal errors. E.g., with
    package test::facetsIn; use strict; use base::Vars qw(%runSwitches); use Carp; # use vars qw(%runSwitches); sub orionDirs{ print("safer::Indenture::facetsIn's directories: " , join(' ', sort keys %{$runSwitches{directories}}), "\n"); print("base::Vars::runSwitches' directories: ", join(' ', sort keys %{$base::Vars::runSwitches{directories}}), "\n"); print("main::runSwitches{directories}'s directories: " , join(' ', sort keys %{$main::runSwitches{directories}}), "\n"); croak unless $runSwitches{directories}{orion_reqs} } 1
    and
    perl -w test/facetsIn.pm Global symbol "%runSwitches" requires explicit package name at test/fa +cetsIn.pm line 8. Global symbol "%runSwitches" requires explicit package name at test/fa +cetsIn.pm line 16. Execution of test/facetsIn.pm aborted due to compilation errors.

      Then that means that your exporting code is broken:

      package base::Vars; # Actually a bunch of others vars in here, but I'm simplifying. use vars qw( %runSwitches ); our @ISA = qw(Exporter); our @EXPORT = qw(%runSwitches);

      Since you hint that this isn't actually the code that you ran and had the problem with, it is risky for me to declare what the problem with it is. But there is certainly a potential problem.

      You don't actually load Exporter.pm. Add 'require Exporter;' or 'use Exporter;'.

      - tye