NAME
Tie::Scalar::Callback - a tied scalar which executes a callback everytime it is used
VERSION
version 0.07
SYNOPSIS
use Tie::Scalar::Callback;
# this coderef doubles the scalar's value everytime it's fetched
my $coderef = sub {
state $value = 1/2;
state $factor = 2;
$value *= $factor;
}
};
tie(my $doubler, 'Tie::Scalar::Callback', $coderef);
print $doubler; 1
print $doubler; 2
print $doubler; 4
DESCRIPTION
Tie::Scalar::Callback
is a class for creating tied scalars which execute a callback everytime an event occurs on the scalar. The callback's return value becomes the scalar's apparent value.
ACKNOWLEDGEMENTS
Thanks to brian d foy for coming up with the idea for this module.
SEE ALSO
AUTHOR
David Farrell <dfarrell@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2016 by David Farrell.
This is free software, licensed under:
The (two-clause) FreeBSD License