Hello all,
I am trying to export by default a variable from a module in the importer namespace, please look at this sample code:
package EXAMPLE;
use strict;
use warnings;
sub import{
my $context = caller;
my $symbol = "$context\:\:my_dirt_sneaky_object_reference";
warn $context;
warn $symbol;
{
no strict 'refs';
*$symbol = \EXAMPLE->new;
}
}
sub new{
my $class = shift;
my $self = {};
return bless $self, $class;
}
sub my_example_method{
print "hi, I am here!";
}
when I call it from a traditional CGI, all works without a glitch:
#!/usr/bin/perl
use lib '/path/to/whateveryoulike';
use EXAMPLE;
$my_dirt_sneaky_object_reference->my_example_method;
When I call the same code from mod_perl (Registry), I get a segmentation fault after the first invocation.
Am I doing any big mistake with mod_perl? Is it the bad way to play with namespaces in mod_perl?
To tell the truth, what I am trying to achieve is a bit more convoluted, but I tried to reduce it to what I believe is the kernel of the problem.
Any idea?
Thanks in advance for tips and advices.
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.