perl and network addresses

Ben Scott dragonhawk at gmail.com
Tue Mar 28 11:03:01 EST 2006


On 3/28/06, Paul Lussier <p.lussier at comcast.net> wrote:
> If you really want the long convoluted discussion, I'll be glad to
> post it, I just figured no on would care.

  Well, everyone here knows *I* thrive on long, convoluted
discussions.  I'm also curious if you're trying to route packets
through a non-existant gateway again.  ;-)

>>       perl -we '$a = inet_addr("192.0.2.42");'
>>
>> but it complained that inet_addr is not defined.
>
> You likely need to use -MSocket, and then figure out which of the
> correct functions in there are analogous to inet_addr.  The ones which
> leap to mind are inet_ntoa and inet_aton.  There doesn't seem to be an
> inet_addr.

  Hmmm.... Well, I just tried that quickly, but it looks like Perl's
inet_aton() function results in something that Perl thinks is a
string, not a long integer.  (Probably because inet_aton() is defined
in terms of a pointer to character(s), in typical C fashion.)  I don't
know how to tell Perl to treat the result as the integer it is (so I
can do binary operations on it).

  Or maybe I'm using it wrong.

-- Ben




More information about the gnhlug-discuss mailing list