I work with a database that stores a pool of IP addresses in numeric form. If any of you have to deal with something similar, here's a handy little function that can convert IP addresses into numeric form.
sub ipToNum { my $ip = shift; my @octets = split(/\./, $ip); my $ip_number = 0; foreach my $octet (@octets) { $ip_number <<= 8; $ip_number |= $octet; } return $ip_number; }
So, for example, if you feed it 192.168.0.1, it will return 3232235521.
In reply to IP to numeric value. by cerror
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |