Hello Monks!
I need to be able to convert integer versions of IPv4 address to the four octet version of the IP address. I have this script that works well but I need to embed this into a scriptlet in an RPM, so I was hoping someone could help stream-line it some.
#!/usr/local/bin/perl -w use strict; my $int = shift || 2130706433; # 127.0.0.1 my $quad4 = $int % 256; $int = int($int/256); my $quad3 = $int % 256; $int = int($int/256); my $quad2 = $int % 256; $int = int($int/256); my $quad1 = $int % 256; print "$quad1.$quad2.$quad3.$quad4\n";
Thanks!
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |