Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

"getaddrinfo" is not exported by the Socket module

by neilwatson (Priest)
on Sep 29, 2012 at 17:39 UTC ( #996406=perlquestion: print w/replies, xml ) Need Help??
neilwatson has asked for the wisdom of the Perl Monks concerning the following question:


I have code.

#!/usr/bin/perl BEGIN { unshift @INC, "/home/neil/perl5/lib/perl5" } use strict; use warnings; use Socket qw( getaddrinfo getnameinfo );

I get this error.

"getaddrinfo" is not exported by the Socket module "getnameinfo" is not exported by the Socket module Can't continue after import errors at /home/neil/bin/ptr line 7. BEGIN failed--compilation aborted at /home/neil/bin/ptr line 7.

This is perl 5.10.1. The default installed Socket version is 1.82. I installed a later version of Socket (see BEGIN), v2.0006. Aren't these sub in Socket?


I'm not set on this path. My goal is to find a host name from an IP address that may be IPV4 or IPV6. I cannot know ahead of time which IP version might be presented.

Neil Watson

Replies are listed 'Best First'.
Re: "getaddrinfo" is not exported by the Socket module
by toolic (Bishop) on Sep 29, 2012 at 17:54 UTC
    I see no mention of getaddressinfo in the POD for perl 5.10.1 at You can look at your installed version with:
    perldoc Socket perldoc -m Socket

    However, perl 5.16 (currently on the web) Socket does mention it:

    The entire getaddrinfo() subsystem can be exported using the tag :addrinfo ; this exports the getaddrinfo() and getnameinfo() functions
Re: "getaddrinfo" is not exported by the Socket module
by syphilis (Chancellor) on Sep 30, 2012 at 05:13 UTC
    BEGIN { unshift @INC, "/home/neil/perl5/lib/perl5" }

    Is the "later version" of located in the /home/neil/perl5/lib/perl5/ directory ?
    I expect it might be in a *sub-directory* of that location. If so, then you'll still be loading the original version of

    Update: Of the various versions of Socket that I have, version 1.94 is the earliest version that exports getaddrinfo. (I have it with perl-5.14. The versions I have with 5.10.0 and 5.12.0 don't export getaddrinfo.)


      The later version of Socket I installed is here: /home/neil/perl5/lib/perl5/x86_64-linux-thread-multi/

      Neil Watson

Re: "getaddrinfo" is not exported by the Socket module
by neilwatson (Priest) on Sep 30, 2012 at 16:41 UTC

    Progress. I installed Socket in local lib. I had to do this to load it:

    #!/usr/bin/perl BEGIN { unshift @INC, "/home/neil/perl5/lib/perl5" } BEGIN { unshift @INC, "/home/neil/perl5/lib/perl5/x86_64-linux-thread- +multi" } use strict; use warnings; use Socket qw ( getnameinfo getaddrinfo );

    If there is a better way I'm all ears. I know I can set a shell environment but, I'm not inclined to trust that once the program is shipped out.

    Neil Watson

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://996406]
Approved by toolic
[Corion]: marto: Ow! You got hit by the storm that is bringing warm weather to me ...
[1nickt]: marto Good to hear that was the worst of it for you...
[marto]: 1nickt the worst I'm aware of at the moment :P
LanX .♩..♬ ... Another one bites the Sahara dust ...
marto wonders what fresh hell the firefox update has brought, apart from maxing out CPUs
1nickt was looking into Firefox Extended Support releases yesterday. You don't have to go with the updates!

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (9)
As of 2017-10-17 12:25 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (230 votes). Check out past polls.