<?xml version="1.0" encoding="windows-1252"?>
<node id="996605" title="symbols, scope, and mod_perl" created="2012-10-01 04:10:50" updated="2012-10-01 04:10:50">
<type id="115">
perlquestion</type>
<author id="969575">
acanfora</author>
<data>
<field name="doctext">
Hello all,
I am trying to export by default a variable from a module in the importer namespace, please look at this sample code:

&lt;code&gt;
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-&gt;new;
        }
}

sub new{
        my $class = shift;
        my $self = {};
        return bless $self, $class;
}

sub my_example_method{
        print "hi, I am here!";
}
&lt;/code&gt;

when I call it from a traditional CGI, all works without a glitch:

&lt;code&gt;
#!/usr/bin/perl
use lib '/path/to/whateveryoulike';
use EXAMPLE;

$my_dirt_sneaky_object_reference-&gt;my_example_method;
&lt;/code&gt;

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.</field>
</data>
</node>
