I've recently been working in a Mason web app and am having issues of the Mason compiler seemingly skipping a used modules'
INIT. Now I must say my intelligence of Mason's uses are moderate at best, so I may very well be missing something. Plus, I'm working in a quite legacy application that is far from perfect. That said, here is an example.
Example of included module
package Foo;
use strict;
use warnings;
INIT {
{
no strict 'refs';
*Foo::bar = sub{ return 1; };
}
}
sub new {
return bless {}, shift;
}
Example of Mason Page
<%init>
use Foo;
</%init>
% print Foo->bar();
Simple enough. But, in this example, I'm seeing that
bar is not defined in
Foo. After further (and intense, multiple times on different yet similar issues) investigation, I can find no proof that the code within the
INIT block is even getting executed. Even more interesting is that knowing Perl as I do, I can't find any reasonable or logical explanation into why or /how/ this could even be happening (unless, maybe, Mason takes it upon it's self to parse included modules and ignore specific code blocks before adding adding them to the
%INC path... but I would hate to believe it does that.)
That's it. Any help appreciated and thanks in advance for your bits of wisdom.
---------
perl -le '$.=[qw(104 97 124 124 116 97)];*p=sub{[@{$_[0]},(45)x 2]};*d=sub{[(45)x 2,@{$_[0]}]};print map{chr}@{p(d($.))}'