Any correlation between me and reality, let alone my opinions and those of my employer, is entirely coincidental
I'm not worthy, I'm not worthy...but I do believe in the interconnectedness of all things...
I have a database that keeps ip addresses stored as 32 bit integers. I have to extract this and make an ascii string for a config file.
If this were C, i'd stuff the address in the appropriate part of in_addr, and call inet_ntoa. Can't see how to get into the structures for Perl.. and all the references i find to inet_ntoa on web searches either
a. get a value using gethostbyname (not applicable)
b. talk about opaque values (which I don't understand)
c. seem to be using a structure, but are not clear how one manipulates the structure.
Here's what I'm trying to do:
use Socket;
#=================================================================
$var=0x0a0a0a01; #simulate the value from the database
printf(STDERR "DEBUG, var is %4.4x \n", $var);
print STDERR "DEBUG, var is $var\n";
$peer_addr = inet_ntoa($var);
print "DEBUG, $peer_addr";
which gives the infamous output of:
DEBUG, var is a0a0a01
DEBUG, var is 168430081
Bad arg length for Socket::inet_ntoa, length is 9, should be 4
9. Hmmm is it relevant that that is the number of digits in the "print" value.. is it being stored in some format other than integer?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.