Set::IntRange is a Perl module (available from CPAN) that allows easy manipulation for sets of integers. It is based (and depends) on Bit::Vector. The module was written by Steffen Beyer.

This module is excellent if you need to manipulate numeric ranges that can be thought of as integers. Here's an example:

#!/usr/bin/perl

use Set::IntRange;

my $day = Set::IntRange->new(6,17);

print "Day:\n";

$day->Flip();
print $day->to_Enum(), "\n";
$day->Flip();

$day->Interval_Fill(8,10);
$day->Interval_Fill(12,16);

print "Events:\n";

print $day->to_Enum(), "\n";

print "Empty events:\n";

$day->Flip();
print $day->to_Enum(), "\n";

This creates a "day", allocates some "time" from it, and then shows what hours of the day are free. Very neat!