Tie::Scalar::MarginOfError is a Perl module that allows you to have a scalar which has to stay within a certain margin of error. Your code will die (or execute what was passed in via the 'callback' subref) if the scalar's value goes outside this range.
You tie a variable, and give it an initial value and a tolerance. Your code will die (or execute what was given in the callback subref) if the value gets beyond +/- whatever you have set the tolerance to be.
In the SYNOPSIS example, $val will cause your code to execute &some_sub if it gets above 1.1 or below 0.9.
If no callback is defined, then the code will simply croak.
SYNOPSIS
use Tie::Scalar::MarginOfError;
tie my $val, 'Tie::Scalar::MarginOfError',
{
tolerance => 0.1,
initial_value => 1,
callback => \&some_sub,
};
Requirements:
· Perl