Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Push to Reference

by VinsWorldcom (Parson)
on Oct 10, 2017 at 11:07 UTC ( #1201096=note: print w/replies, xml ) Need Help??


in reply to Push to Reference

Looks like haukex may have solved your problem above, so just an observation:

  • It's 2017, we really should be using address family independent Socket routines.

Unless you're *guaranteed* that:

  • @ips will only be IPv4 addresses, or
  • you're on a Perl older than 5.14, or
  • your Socket module version is older than 1.94, or
  • you're using an operating system circa Windows XP ...

you may encounter IPv6. So planning for it is easy:

#!perl use strict; use warnings; my @bla = qw ( 34.230.53.172 2607:f8b0:400d:c0b::63 ); for my $bla (@bla) { ### What you need below ### use Socket qw( AF_INET IPPROTO_TCP ); my $AF_UNSPEC = eval { Socket::AF_UNSPEC() }; my $NI_NAMEREQD = eval { Socket::NI_NAMEREQD() }; my %hints = ( family => $AF_UNSPEC, protocol => IPPROTO_TCP ); my ( $err, @getaddr ) = Socket::getaddrinfo( $bla, undef, \%hints ); for my $addr (@getaddr) { my ( $err, $host, $service ) = Socket::getnameinfo( $addr->{addr}, $NI_NAMEREQD ); printf "%s\n", ( defined($host) ) ? $host : $err; } ### What you need above ### }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1201096]
help
Chatterbox?
[Discipulus]: good morning monks and nuns!
[Corion]: Hi Discipulus, Happy-the-monk!
[Corion]: There is demand for an emergency Frankfurt.pm social meeting, as two people from Strasbourg.pm are in Frankfurt on Wednesday - I'll forward the mail in the evening
[Discipulus]: beer finished in Strasbourg? ;=)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2018-07-23 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (459 votes). Check out past polls.

    Notices?