Problem Calling Embedded Function within OO Perl - Namespace Issue??
Posted on 2004-04-03
I am obviously missing something in this simplified example. I have a 'custom module' for the function I have written over time.
This module uses function from other modules. For this example - I am using a function from the Date::Manip module.
I am trying to use these functions from an instance of the Net::Server class. When I call my custom function from a normal perl program or from another module - I have no problem. When I call my custom from within the child_init_hook sub of the Net::Server module - the ParseDateString function causes the subroutine to end. Note that no error message occurs and Net::Server continues to run - the sub routine (child_init_hook) just stops executing.
What makes this problem even more bizzare is that if I call my test function 'pdate' before I start the run method (note: i have this line commented out in the text below)- everything works fine. I am obviously missing something obvious about object oriented perl.
************ Sample Code - Main Program
use vars qw(@ISA);
use Net::Server::PreFork qw(:DEFAULT /^/);
@ISA = qw(Net::Server::PreFork);
#$a=pdate("20020101"); # If this line is not commented out - pdate in child_init_hook works!!
print "initializing process id $$\n";
print "f $a\n";
********** Sample Module
use base qw(Exporter);
use vars qw(@EXPORT @EXPORT_OK @INC);
@EXPORT = qw(&pdate);
my ($y) = @_;
print "after $a\n";