[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Perl bug?



>>>>> "ML" == Martin Lathoud <nytral@enDirect.qc.ca> writes:

ML> B'jour,
ML> j'ai cherche dans bugs.debian.org/perl sans succes.. :

ML> ($name,$aliases,$addrtype,$length,@addrs)=gethostbyname('hp.com');
ML> print "$name,$aliases,$addrtype,$length\n";
ML> foreach (@addrs) {

        printf("%d.%d.%d.%d\n",unpack('C4',$_));

ML> };


$ perldoc -f gethostbyname | tail -6                                           
addresses returned by the corresponding system library call.  In the
Internet domain, each address is four bytes long and you can unpack it
by saying something like:

    ($a,$b,$c,$d) = unpack('C4',$addr[0]);


$ perl test.pl                                                                 
hp.com,,2,4
192.6.35.16
192.151.11.13
192.151.11.32
192.151.52.13

j'ai bon ? :-)


Cordialement,
seb.
-- 
<< I do not take drugs; I am drugs >>	
						Salvator Dali


Reply to: