🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.perl
Article #257

Re: gethostbyaddr()

#257
From: Marcin Benke
Date: Thu, 15 May 1997 11:38
47 lines
1871 bytes
In article <Pine.GSO.3.96.970515105108.18403A-100000@netra.gdansk.sprint.pl> Alan Ghafour <alan@gdansk.sprint.pl> writes:

   Probuje zrobic gethostbyaddr() i za ... mi nie wychodzi :-(
   Moze ktos przesledzi ponizszy kawalek i powie gdzie jest blad ?

 [amba]

   # Ani tak ...
   $name=gethostbyaddr($addr,AF_INET);
   print $name, "\n";

   # Ani tak
   $addr=pack("C4",$a,$b,$c,$d);
   $name=gethostbyaddr($addr,AF_INET);
   print $name,"\n";


A ja napisałem tak:

use Socket 'AF_INET' ;

@a = split('\.', $ARGV[0], 4);
$addr=pack("C4",@a);
$name=gethostbyaddr($addr, AF_INET);
print $name, "\n";

I działa:

38 herbata:/home/zls/benke> perl -w gha.pl 148.81.12.165
kawa
39 herbata:/home/zls/benke> perl -w gha.pl 128.214.6.100
orava-e.funet.fi

Myślę, że problem leży w tym AF_INET, bo jak wykomentuję linijkeę
z "use Socket...", to perl krzyczy:

40 herbata:/home/zls/benke> perl -w gha.pl 128.214.6.100
Argument "AF_INET" isn't numeric in ghbyaddr at gha.pl line 7.
Use of uninitialized value at gha.pl line 8.
 

Morał: używać opcji -w

Pozdrawiam,
		Marcin Benke
----------------------------------------------------------------------------
"Calm down, it's only ones and zeros!" -  DJ Delorie
Technical Details
Message-ID: <omlo5hc6dr.fsf@herbata.mimuw.edu.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!news.icm.edu.pl!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!pingwin.icm.edu.pl!news.icm.edu.pl!not-for-mail
From: ben@herbata.mimuw.edu.pl (Marcin Benke)
Newsgroups: pl.comp.lang.perl
Subject: Re: gethostbyaddr()
Date: 15 May 1997 13:38:24 +0200
Organization: Institute of Informatics, Warsaw University
Lines: 52
Sender: ben@herbata.mimuw.edu.pl
Message-ID: <omlo5hc6dr.fsf@herbata.mimuw.edu.pl>
NNTP-Posting-Host: herbata.mimuw.edu.pl
Mime-Version: 1.0
In-reply-to: Alan Ghafour's message of Thu, 15 May 1997 11:01:22 +0200
X-Newsreader: Gnus v5.1
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit