NAME

OP::Subnet - Overloaded Subnet object

SYNOPSIS

use OP::Subnet;

my $addr = OP::Subnet->new("10.0.0.0/24");

DESCRIPTION

Simple class to represent subnets as strings.

Extends OP::Str. Uses Net::Subnets to expand ranges.

PUBLIC CLASS METHODS

  • $class->assert(@rules)

    Returns a new OP::Type::Subnet instance which encapsulates the received OP::Subtype rules.

    create "OP::Example" => {
      someAddr  => OP::Subnet->assert( subtype(...) ),
    
      # ...
    };
  • $class->new($addr);

    Returns a new OP::Subnet instance which encapsulates the received value.

    my $subnet = OP::Subnet->new("10.0.0.0/24");

PUBLIC INSTANCE METHODS

  • $self->list

    Return a new OP::Array containing each IP in self's range.

    $subnet->list->each( sub {
      my $ip = shift;
    
      print "Have IP address: $ip\n";
    } );

SEE ALSO

OP::Str, OP::Array, Net::Subnets

This file is part of OP::Net.