Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
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.

In reply to symbols, scope, and mod_perl by acanfora

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (17)
    As of 2015-07-28 15:48 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (257 votes), past polls