I wrote a perl script that will convert both ways because I was tired of
doing this with pencil and paper...

Feed it an IP address in dotted notation and it will convert it to
decimal... feed it decimal and it will convert it to a dotted notation IP.
Feed it anything else and it will spit out unspecified garbage =)

me@box> ./ac 207.25.71.30
3474540318
me@box> ./ac 3474540318
207.25.71.30

-----------
#!/usr/bin/perl -w
use strict;

my $t = "";
my $o = 0;
if ($ARGV[0] !~ /\./) {
  $ARGV[0] =~ s/(\d+)/sprintf "%02X",$1/eg;
  $ARGV[0] = ("0" x (8 - length($ARGV[0]))) . $ARGV[0];
  while ($o < 8) {
    $t .= hex(substr($ARGV[0], $o, 2)) . ".";
    $o += 2;
  }
  print substr($t, 0, (length($t) - 1)) . "\n";
} else {
  my @p=split(/\./, $ARGV[0]);
  foreach (@p) {
    $o = sprintf "%lx", $_;
    if (length($o) == 1) { $o = "0${o}"; }
    $t .= $o; 
  }
  print hex($t) . "\n";
}

-----Original Message-----
From: Frost, Ron [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, April 25, 2001 10:44 AM
To: 'Mark Watts'; 'Swapnil Wadikar'; [EMAIL PROTECTED]
Subject: RE: dword convertion


If you have a PDA, I found a nice little conversion program a while back
that does this with ease (since my binary ain't what it used to be):
http://bnsi.pda.tucows.com/palm/preview/33608.html

Ron...
-
[To unsubscribe, send mail to [EMAIL PROTECTED] with
"unsubscribe firewalls" in the body of the message.]

Reply via email to