Perhaps something like this?
#!/usr/bin/perl use strict; use warnings; while (my $line = <DATA>) { chomp $line; if ($line =~ m/in-addr/) { my @line = split(/\./, $line); if ($line[2] =~m/in-addr/) { process_line("$line[1]\." ."$line[0]\." . "0\." . "0" . " +\/24"); } else { process_line("$line[2]\." . "$line[1]\." ."$line[0]\." . " +0" . "\/16" ); } } else { process_line($line); } } sub process_line { print shift . "\n"; # do whatever... } __DATA__ 250.26.192.in-addr.arpa,3 251.26.192.in-addr.arpa,3 252.26.192.in-addr.arpa,3 253.26.192.in-addr.arpa,3 254.26.192.in-addr.arpa,3 26.192.in-addr.arpa,2 hosangit.com djzah.com
Output
192.26.250.0/16 192.26.251.0/16 192.26.252.0/16 192.26.253.0/16 192.26.254.0/16 192.26.0.0/24 hosangit.com djzah.com
Hope that is helpful....
Insanity: Doing the same thing over and over again and expecting different results...
In reply to Re: Method to Parse IP 2 Array
by wjw
in thread Method to Parse IP 2 Array
by djzah71
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |