Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

"getaddrinfo" is not exported by the Socket module

by neilwatson (Curate)
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:

Greetings,

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?

update

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
watson-wilson.ca

Comment on "getaddrinfo" is not exported by the Socket module
Select or Download Code
Re: "getaddrinfo" is not exported by the Socket module
by toolic (Chancellor) on Sep 29, 2012 at 17:54 UTC
    I see no mention of getaddressinfo in the POD for perl 5.10.1 at http://perldoc.perl.org/5.10.1/Socket.html. 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 (Canon) on Sep 30, 2012 at 05:13 UTC
    BEGIN { unshift @INC, "/home/neil/perl5/lib/perl5" }

    Is the "later version" of Socket.pm 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 Socket.pm.

    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.)

    Cheers,
    Rob

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

      Neil Watson
      watson-wilson.ca

Re: "getaddrinfo" is not exported by the Socket module
by neilwatson (Curate) 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
    watson-wilson.ca

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://996406]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2014-12-27 03:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (176 votes), past polls