#!/usr/bin/perl 

# You can retrieve this module (and Bit::Vector, which it requires) from
# the CPAN at http://www.perl.com/CPAN/modules/by-module.
use Set::IntRange;

# Create the integer range.  The bounds can be zero or negative.
# All that is required is that the lower limit (the first
# argument) be less than upper limit (the second argument).

$range = new Set::IntRange(1, 1000);

# Turn on the bits (members) from 100 to 200 (inclusive).

$range->Interval_Fill( 100,200 );

# Turn off the bit 123, the bit 345 on, and toggle bit 456.

$range->Bit_Off ( 123 );
$range->Bit_On  ( 345 );
$range->bit_flip( 456 );

# Test bit 123.

print "bit 123 is ", $range->bit_test( 123 ) ? "on" : "off", "\n";

# Testing bit 9999 triggers an error because the range ends at 1000.
# print "bit 9999 is on\n" if $range->bit_test( 9999 );

# Output the integer range in text format.
# This format is a lot like the "runlist" format of Set::IntSpan;
# the only difference is that instead of '-' in ranges the Perlish
# '..' is used.  Set::IntRange also knows how to decode
# this format, using the method from_Hex().
#

print $range->to_Hex, "\n";
