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($.))}'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.