Yes it is possible, but it is not recommended. I just ran into a problem with a module on CPAN that suffers from a circular dependency that crops up in the strangest ways. It has to do with the fact that it is importing functions in a circular dependancy, which by the way is exactly what you are suffering from. Here is an example:
#!/usr/bin/perl
use Crypt::Random;
use Crypt::Random::Generator;
my $gen = new Crypt::Random::Generator Strength => 0;
print $gen->integer(Upper => 100), $/;
The above will fail (if you are using version 1.13 of Crypt::Random) with the following error:
Undefined subroutine &Crypt::Random::Generator::makerandom_itv called at lib/Crypt/Random/Generator.pm line 82.
Which looks pretty similar to your problem!
The solution is to fully qualify your functions instead of importing them (ie use cspace::chelp in your bspace module).
What can make this really frustrating, is that the module may appear to work correctly in most instances, but if the modules get used in the wrong order, you hit a problem. Check out the following code snippet which also triggers the Crypt::Random circular reference bug.
#!/usr/bin/perl
use Tk;
use Net::SFTP;
my $sftp = Net::SFTP->new('localhost');
Which spews out the following errors:
"makerandom" is not exported by the Crypt::Random module
"makerandom_itv" is not exported by the Crypt::Random module
"makerandom_octet" is not exported by the Crypt::Random module
Can't continue after import errors at /usr/local/share/perl/5.8.2/Cryp
+t/Random/Generator.pm line 12
BEGIN failed--compilation aborted at /usr/local/share/perl/5.8.2/Crypt
+/Random/Generator.pm line 12, <GEN0> line 1.
Compilation failed in require at /usr/local/share/perl/5.8.2/Crypt/Ran
+dom.pm line 18, <GEN0> line 1.
BEGIN failed--compilation aborted at /usr/local/share/perl/5.8.2/Crypt
+/Random.pm line 18, <GEN0> line 1.
Compilation failed in require at ../Crypt-DH-0.03/lib//Crypt/DH.pm lin
+e 6, <GEN0> line 1.
BEGIN failed--compilation aborted at ../Crypt-DH-0.03/lib//Crypt/DH.pm
+ line 6, <GEN0> line 1.
Compilation failed in require at ../Net-SSH-Perl-1.25/lib//Net/SSH/Per
+l/Kex/DH1.pm line 13, <GEN0> line 1.
BEGIN failed--compilation aborted at ../Net-SSH-Perl-1.25/lib//Net/SSH
+/Perl/Kex/DH1.pm line 13, <GEN0> line 1.
Compilation failed in require at ../Net-SSH-Perl-1.25/lib//Net/SSH/Per
+l/Kex.pm line 6, <GEN0> line 1.
BEGIN failed--compilation aborted at ../Net-SSH-Perl-1.25/lib//Net/SSH
+/Perl/Kex.pm line 6, <GEN0> line 1.
Compilation failed in require at ../Net-SSH-Perl-1.25/lib//Net/SSH/Per
+l/SSH2.pm line 6, <GEN0> line 1.
BEGIN failed--compilation aborted at ../Net-SSH-Perl-1.25/lib//Net/SSH
+/Perl/SSH2.pm line 6, <GEN0> line 1.
Compilation failed in require at ../Net-SSH-Perl-1.25/lib//Net/SSH/Per
+l.pm line 51, <GEN0> line 1.
Not very nice is it... So the moral of the story is, don't use circular references, and if you really have to, fully qualify your functions.
- Cees |