Steve Sotis wrote:
>
> BTW, the answer to this (and it was not a trick) question was that the
> array elements were backwards, i.e. this is wrong:
>
> $long_current_ip = (@current_ip[0] * 16777216) +
> (@current_ip[1] * 65536) + (@current_ip[2] * 256) + @current_ip[3];
>
> and this
>
> $long_current_ip = (@current_ip[3] * 16777216) +
> (@current_ip[2] * 65536) + (@current_ip[1] * 256) + @current_ip[0];
>
> and this
>
> $long_current_ip = (@current_ip[3] << 24) + (@current_ip[2] << 16)
> + (@current_ip[1] << 8) + @current_ip[0];
>
> are correct.
First, sorry that I didn't take time to write a solution that directly
solved your problem; but, following does it quite efficiently:
print unpack("I*", inet_aton($current_ip)), "\n";
This obviates need for split and does everything in one (1) line.
Also, you would do well to run *both*
perl -w
use strict
since your solutions use slices; rather than the array elements you want
;>
Hope this helps . . .
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web