pprindeville has asked for the wisdom of the Perl Monks concerning the following question:

I'm the owner/maintainer of Net::Patricia, and I was trying to get ready for a new release.

Since the module can't be used without importing AF_INET and AF_INET6 from Socket and Socket6 respectively, I figured I'd simplify things a bit by having my module export those two symbols directly into the caller.

I did this as:

use Socket qw(AF_INET inet_aton inet_ntoa); use Socket6 qw(AF_INET6 inet_pton inet_ntop); BEGIN { require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); @EXPORT = qw(AF_INET AF_INET6); }

You can see the entire file here.

However, when I installed the updated module and tried to use it in production with Mimedefang, I started seeing the following errors:

Nov 16 14:44:58 mail mimedefang-multiplexor[15764]: Slave 1 stderr: Pr +ototype mismatch: sub main::AF_INET6 () vs none at /usr/lib/perl5/5.1 +0.0/Exporter.pm line 66.#012 at /etc/mail/mimedefang-filter line 1479

Odd that this happens for Socket6::AF_INET6 but not for Socket::AF_INET.

Both are implemented nearly identically.

This is holding up a release, and frankly I can't figure it out, after staring at it for the better part of the day.

Like a lot of issues in Perl, it's probably something frustratingly trivial, but I'm not seeing it.

Anyone else think they might have strong mojo?

Thanks.

Replies are listed 'Best First'.
Re: Trying to cleanly re-export another Module's export constants
by cdarke (Prior) on Nov 23, 2009 at 11:52 UTC
    In my version (Socket6 is 0.22 and Socket is 1.82) when I try your code I get:
    "AF_INET6" is not exported by the Socket6 module
    Inspecting the code somewhat I see in Socket6.pm:
    push @EXPORT, qw(AF_INET6) unless defined eval {Socket::AF_INET6()};
    and indeed the version of Socket.pm I have does export AF_INET6. Changing your code a little works for me:
    use warnings; use strict; use Socket qw(AF_INET6 AF_INET inet_aton inet_ntoa); use Socket6 qw(inet_pton inet_ntop); BEGIN { require Exporter; require DynaLoader; our @ISA = qw(Exporter DynaLoader); our @EXPORT = qw(AF_INET AF_INET6); }
    Maybe you need some sort of test in a BEGIN block to see if the user's Socket.pm exports AF_INET6.