in reply to How to share the global variables between two modules by using Perl CLI Framework?
Anyway, that aside - the reason you get those to errors, is because the module 'runs' when you import it. The print statements on like 63 and 75 aren't encapsulated within a subroutine, so they run at the same time as you import the module - which is before the 'init' subroutine is called.
You will get the same error with a blank script that just has the 'use' lines in it, I think.
And script:#!/usr/bin/perl use strict; use warnings; package testfish; sub sub_to_do_something { print "Doing something \n"; } print "FISH\n"; 1;
Gives an output of:#!/usr/bin/perl use strict; use warnings; use testfish; print "Not done anything with the module yet\n"; &testfish::sub_to_do_something();
Which is more or less the same as you're doing with that 'print' line in your modules. Init hasn't been called yet. (I assume it's something that CLI::Framework requires and uses later).FISH Not done anything with the module yet Doing something
|
|---|