https://github.com/dnmfarrell/tie-scalar-callback
A scalar which executes a callback every time is used
https://github.com/dnmfarrell/tie-scalar-callback
Last synced: over 1 year ago
JSON representation
A scalar which executes a callback every time is used
- Host: GitHub
- URL: https://github.com/dnmfarrell/tie-scalar-callback
- Owner: dnmfarrell
- License: other
- Created: 2016-01-26T04:30:34.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-01T14:00:37.000Z (over 9 years ago)
- Last Synced: 2025-01-16T16:49:19.796Z (over 1 year ago)
- Language: Perl
- Size: 12.7 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
- License: LICENSE
Awesome Lists containing this project
README
=pod
=encoding UTF-8
=head1 NAME
Tie::Scalar::Callback - a tied scalar which executes a callback everytime it is used
=head1 VERSION
version 0.062
=head1 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
=head1 DESCRIPTION
C 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.
=head1 ACKNOWLEDGEMENTS
Thanks to L for coming up with the idea for this module.
=head1 SEE ALSO
=over 4
=item *
L
=item *
L
=item *
L
=back
=head1 AUTHOR
David Farrell
=head1 COPYRIGHT AND LICENSE
This software is Copyright (c) 2016 by David Farrell.
This is free software, licensed under:
The (two-clause) FreeBSD License
=cut