Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: novice falls

by wog (Curate)
on Oct 11, 2001 at 03:41 UTC ( [id://118127]=note: print w/replies, xml ) Need Help??


in reply to novice falls

You have to problems with your arguments passed to gethostbyaddr. First, you are correct that $& is not in the correct format. You must pass it in packed address format, which can be done using Socket's inet_aton to convert the address from readable dotted form to network-ordered bytes. (Perl's "version strings" appear to generate a similarlly formatted string.) Secondly, the second arg to gethostbyaddr needs to be a valid type of address, which would be AF_INET, probably. You do not want 'tcp', because that is a protocol, not a type of address. (In fact, TCP can and does have different types of addresses, with IPv6.)

Note that it is a good idea to use capturing parenthesis instead of $&, because capturing parenthesis tend to make your program faster. (See also perlvar.)

Replies are listed 'Best First'.
Re: Re: novice falls
by Fletch (Bishop) on Oct 11, 2001 at 08:18 UTC

    Actually, with recent perls $& isn't too bad ($' and $` still garner a performance hit). See perldoc -q 'slow my program' for more details. (Not that you shouldn't use capturing parens though; just clearing up an old meme).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://118127]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found