in reply to Need a better way to break out a range of addresses...
#!/usr/bin/perl use strict; use warnings; use Set::CrossProduct; while (<DATA>) { chomp; s/\s*#.+//; my @data; while (/([^.]+)/g) { if ($1 =~ /(\d+)-(\d+)/) { push @data, [$1..$2]; } else { push @data, [$1]; } } for (Set::CrossProduct->new( \@data )->combinations) { print join(".", @$_), "\n"; } } __DATA__ 172.17.119.2 # Comments are here... 172.17.119.4-5 # Comments are here... 172.19-21.254.2-3 # Comments are here... 192.168.1.1-3 # Comments are here...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need a better way to break out a range of addresses...
by brian_d_foy (Abbot) on Mar 29, 2007 at 04:18 UTC | |
by Cristoforo (Curate) on Apr 02, 2007 at 15:36 UTC |