Show
Ignore:
Timestamp:
08/21/08 10:32:07 (6 years ago)
Author:
tokuhirom
Message:

refactoring

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Net-CIDR-MobileJP/trunk/lib/Net/CIDR/MobileJP.pm

    r17904 r17944  
    2323    my ($class, $stuff) = @_; 
    2424 
    25     return bless {spanner => $class->_create_spanner($stuff)}, $class; 
     25    return bless {spanner => $class->_create_spanner($class->_load_config($stuff))}, $class; 
    2626} 
    2727 
    2828sub _create_spanner { 
    29     my ($class, $stuff) = @_; 
     29    my ($class, $conf) = @_; 
    3030 
    31     my @cidrs; 
    32     my %cidr_for = %{$class->_load_config($stuff)}; 
    33     my $spanner = Net::CIDR::Lite->new->spanner; 
    34     while (my ($carrier, $ip_ranges) = each %cidr_for) { 
    35         my $cidr = Net::CIDR::Lite->new; 
    36         for my $ip_range (@$ip_ranges) { 
    37             $cidr->add($ip_range); 
    38         } 
    39         $spanner->add($cidr, $carrier); 
     31    my $spanner = Net::CIDR::Lite::Span->new; 
     32    while (my ($carrier, $ip_ranges) = each %$conf) { 
     33        $spanner->add(do { 
     34            my $cidr = Net::CIDR::Lite->new; 
     35            for my $ip_range (@$ip_ranges) { 
     36                $cidr->add($ip_range); 
     37            } 
     38            $cidr; 
     39        }, $carrier); 
    4040    } 
    4141    return $spanner;