in reply to require and its subs
I whipped up a couple of files to test, and had no problem. try.pl looked like this:The file must return true as the last statement to indicate successful execution of any initialization code, so it's customary to end such a file with "1;" unless you're sure it'll return true otherwise. But it's better just to put the "1;", in case you add more statements.
and try.req looked like this:use strict; use warnings; require 'try.req'; my $def = $::DEF{'two'}; mkDec($def);
Output from running try.pl wasprint "I'm loaded\n"; %DEF = (one => 1, two => 2); sub mkDec{ print "MkDec received ($_[0]) OK\n"; } 1;
Name "main::DEF" used only once: possible typo at try.pl line 7 I'm loaded MkDec received (2) OK
|
|---|