rigadon
09-24-2004, 12:24 PM
I have a functions library 'functions.pl' which I 'require' in a script. This is so that I can use the function 'write_log' that is contained within the library.
I also 'use' a module 'SOAP_User' in my script. This module also 'require's the same 'functions.pl' library.
My code is as follows:
package SOAPAtlas;
use strict;
use SOAP_User;
require 'functions.pl';
my $err_file = "soap/err";
unless (&write_log($err_file, "Starting SOAP server"))
{ die "Unable to open server error file $err_file\n";
}
...
package SOAP_User;
use DBI;
use strict;
require 'functions.pl';
sub new
{ my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless ($self, $class);
return $self;
}
...
I get the following error whenever I run this code:
Undefined subroutine &SOAPAtlas::write_log called at soap_server.pl line 30.
However, if I remove the "require 'functions.pl';" line from the SOAP_User module it all works fine, until the SOAP_User module attempts to call write_log when I get a run-time error.
This is presumably to do with require only loading a specific library once but how do I get around the problem?
Cheers
I also 'use' a module 'SOAP_User' in my script. This module also 'require's the same 'functions.pl' library.
My code is as follows:
package SOAPAtlas;
use strict;
use SOAP_User;
require 'functions.pl';
my $err_file = "soap/err";
unless (&write_log($err_file, "Starting SOAP server"))
{ die "Unable to open server error file $err_file\n";
}
...
package SOAP_User;
use DBI;
use strict;
require 'functions.pl';
sub new
{ my $proto = shift;
my $class = ref($proto) || $proto;
my $self = {};
bless ($self, $class);
return $self;
}
...
I get the following error whenever I run this code:
Undefined subroutine &SOAPAtlas::write_log called at soap_server.pl line 30.
However, if I remove the "require 'functions.pl';" line from the SOAP_User module it all works fine, until the SOAP_User module attempts to call write_log when I get a run-time error.
This is presumably to do with require only loading a specific library once but how do I get around the problem?
Cheers