NAME

Net::BART - Balanced Routing Tables for IPv4 and IPv6

SYNOPSIS

use Net::BART;

my $table = Net::BART->new;

# Insert prefixes with values
$table->insert("10.0.0.0/8", "private-10");
$table->insert("10.1.0.0/16", "office");
$table->insert("192.168.1.0/24", "home");
$table->insert("2001:db8::/32", "documentation");

# Longest-prefix match lookup
my ($val, $ok) = $table->lookup("10.1.2.3");
# $val = "office", $ok = 1

# Exact match
my ($val, $ok) = $table->get("10.0.0.0/8");

# Containment check
my $found = $table->contains("10.1.2.3");  # 1

# Delete
my ($old, $ok) = $table->delete("10.1.0.0/16");

# Walk all prefixes
$table->walk(sub {
    my ($prefix, $value) = @_;
    print "$prefix => $value\n";
});

DESCRIPTION

BART implements a multibit trie with fixed 8-bit strides for fast IP prefix lookup. Based on Knuth's ART (Allotment Routing Tables) algorithm with popcount-compressed sparse arrays for memory efficiency.

Based on https://github.com/gaissmai/bart.