in reply to inet_ntoa question

It is being stored as an int. The problem is that inet_ntoa takes a 4 character string as an argument. You need to do something like:
$var=chr(0x0a).chr(0x0a).chr(0x0a).chr(0x01); # OR $var=v10.10.10.1; #using the v-string notation if your perl is new en +ough # OR $var=pack "CCCC", 10, 10, 10, 1; # OR (probably best yet) $var=inet_aton 0x0a0a0a01;
To get the proper string format to feed to inet_ntoa

Replies are listed 'Best First'.
Re: Re: inet_ntoa question
by Funkster (Initiate) on Mar 04, 2004 at 23:52 UTC
    Any correlation between me and reality, let alone my opinions and those of my employer, is entirely coincedental
    Thankx, guys. I have a working solution.. (inet_ntoa(pack). and info that wasn't clear ntoa takes 4 chars). next task is to read up on pack and integer representation.... it's not clear to an old C guy why integer is different than the 4 concatenated characters you suggest.... if I cat the 4 1 byte chars x0a. 0xa . 0xa . 0x01 how is that different than the 32 bit value 0A0A0A01 that I had originally? mu la mi. guess I need to RTFM to figure out what really need to ask.