- AUTHOR, COPYRIGHT AND LICENSE
- SEE ALSO
- CODE REPOSITORY AND ISSUE REPORTING
- TODO: more pod???
BRIANG::Dist::Perfect - A perfect distribution for a perfect year. Or perhaps not.
This is version 0.0101 released 2020-11-21
# Object-oriented interface use BRIANG::Dist::Perfect; my $C1 = BRIANG::Dist::Perfect->new(); say $C1->peek(); # 0 say $C1->counter(); # 1 say $C1->counter(); # 2 my $C2 = BRIANG::Dist::Perfect->new(3); say $C2->peek(); # 3 say $C2->counter(); # 4 say $C2->counter(); # 5 say $C1->counter(); # 3 say $C2->counter(); # 6 # Functional interface use BRIANG::Dist::Perfect qw(:all); set(3); say view(); # 3 say bump(); # 4 say view(); # 4 say bump(); # 5 say bump(); # dies
This module is the principal component from the
What a wonderful year 2020 has been, and to cap it off, here's my perfect distribution.
I intend this distribution to follow every Perl best practice I can. There is a section below with an exhaustive collection of documentation.
This "dummy" module implements a counter accessible through a functional or object-oriented interface.
Important note regarding the functional interface
Due to limitations in the implementation, the functional implementation cannot count beyond 5 and will throw an exception if asked to do so.
No functions are exported automaticaly, but
view() will be exported on request. Alternatively, the export tag ':all' may be used to export all three functions.
$next_counter_value = bump()
Increases the counter by one and returns the new value.
bump() would normally have returned the value 6.
Initialises the counter to
$initial_value, or zero if
$initial_value is omitted.
set() is called with
$initial_value >= 6.
$counter_value = view()
$counter = BRIANG::Dist::Perfect->new($initial_value)
Initialises a new counter object, and returns it.
$initial_value is optional and is used to set an initial value for the counter. Zero is used if the argument is omitted.
$next_counter_value = $counter->count()
Adds one to the counter and returns the new value.
$counter_value = $counter->peek()
Returns the value of the counter without incrementing its value.
Copyright 2020 Brian Greenfield <briang at cpan dot org>
This is free software. You can use, redistribute, and/or modify it under the terms laid out in the MIT licence.
Issues should be reported using the project's GitHub issue tracker.
Contributions are welcome. Please use GitHub Pull Requests.