https://github.com/dnmfarrell/tie-scalar-ratio
a scalar which multiplies its value each time it is accessed
https://github.com/dnmfarrell/tie-scalar-ratio
Last synced: about 2 months ago
JSON representation
a scalar which multiplies its value each time it is accessed
- Host: GitHub
- URL: https://github.com/dnmfarrell/tie-scalar-ratio
- Owner: dnmfarrell
- License: other
- Created: 2016-01-22T04:02:12.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-01-22T04:03:50.000Z (over 10 years ago)
- Last Synced: 2025-01-16T16:49:28.207Z (over 1 year ago)
- Language: Perl
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.pod
- License: LICENSE
Awesome Lists containing this project
README
=pod
=encoding UTF-8
=head1 NAME
Tie::Scalar::Ratio - a scalar which multiplies in value every time it is accessed.
=head1 VERSION
version 0.01
=head1 SYNOPSIS
use Tie::Scalar::Ratio;
tie(my $doubler, 'Tie::Scalar::Ratio', 2, 1);
print $doubler; # 1
print $doubler; # 2
print $doubler; # 4
print $doubler; # 8
tie(my $halver, 'Tie::Scalar::Ratio', 0.5, 80);
print $halver; # 80
print $halver; # 40
print $halver; # 20
print $halver; # 10
=head1 DESCRIPTION
C is a class for creating tied scalars which multiply their
value by a ratio everytime their value is read. I found this a useful way to
make a C function increase its sleep duration after every attempt,
without re-writing the function (I just passed a C object
as the duration scalar).
Similarly by passing a ratio value less than 1, it can be used as a timeout or
countdown feature.
=head1 SEE ALSO
L
=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