NAME

Tie::NumRange - Keeps a number within a range of values.

SYNOPSIS

use Tie::NumRange;

tie my($chr), Tie::NumRange => (
  100,  # initial
  0,    # min
  255,  # max
);

$chr *= 3;  # $chr is 255
$chr = -5;  # $chr is 0

tie my($positive), Tie::NumRange => (
  1,
  1,
  undef
);

$positive = 2**16;  # ok
$positive = 0;      # $pos is 1

DESCRIPTION

This module institutes a range of values for a number. The lower and upper bounds can be unlimited by passing undef in their place.

Constructor

tie $number, Tie::NumRange => ($init, $min, $max);

If $min is undef, the number has no lower bound. Likewise for $max.

AUTHOR

Jeff "japhy" Pinyan
CPAN ID: PINYAN
japhy@pobox.com
http://www.pobox.com/~japhy/