An open API service indexing awesome lists of open source software.

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

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