IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 2 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Perl vs. Java
I'm writing a function that (almost) gets the hostname of an aliased machine.

In Perl

sub normalizeHostname($)
{
   my $hostValue = shift;
   my $rtn = gethostbyaddr(inet_aton($address), AF_INET)
   print STDERR "DEBUG - rtn = " . $rtn . "\\n";
}


In Java

private String normalizeHostName(String hostname) throws UnknownHostException
{
   String rtn = java.net.InetAddress.getByName(hostname).getHostName();
   return rtn;
}



Okay, my question is why am I getting two different answers? Same system, executed from the same command line.
New It has aliased names or addresses?
The thing that makes me go hmmmm is that you are getting the ip address in Java by handing it the hostname.

In perl, you already have the address? How does $address relate to $hostValue in the perl?




"Whenever you find you are on the side of the majority, it is time to pause and reflect"   --Mark Twain

"The significant problems we face cannot be solved at the same level of thinking we were at when we created them."   --Albert Einstein

"This is still a dangerous world. It's a world of madmen and uncertainty and potential mental losses."   --George W. Bush
New They've done evil things to these boxes...
they're part of our testing environment.

These boxes have multiple network cards (and multiple IP addresses) and aliases. (And yes, it is an alias.)
New Perl coding tip
Do not use prototypes in Perl. They don't do what you think, and they do a lot of things that you don't want.

For details read [link|http://library.n0i.net/programming/perl/articles/fm_prototypes/|FMTYEWTK About Prototypes].

Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
     Perl vs. Java - (Simon_Jester) - (3)
         It has aliased names or addresses? - (tuberculosis) - (1)
             They've done evil things to these boxes... - (Simon_Jester)
         Perl coding tip - (ben_tilly)

Almost, but not quite, entirely unlike tea.
64 ms