BRIANG::Dist::Perfect - A perfect distribution for a perfect year. Or perhaps not.
This is version 0.1.0 released 2020-11-17
# 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
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 imnplements 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 bump(), set() and view() will be exported on request. Alternatively, the export tag ':all' may be used to export all three functions.
bump()
set()
view()
$next_counter_value = bump()
Increases the counter by one and returns the new value.
Six encountered
Thrown whenever bump() would normally have returned the value 6.
set($initial_value)
Initialises the counter to $initial_value, or zero if $initial_value is omitted.
$initial_value
Thrown whenever set() is called with $initial_value >= 6.
$counter_value = view()
$counter = new($initial_value)
Initialises a new counter object, and returns it. The optional argument $initial_value sets an initial value for the counter. A value of 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 library is free software. You can use, redistribute, and/or modify it under the terms laid in the MIT licence.
CPAN::Meta::Spec
ExtUtils::MakeMaker
Release::Checklist
Github Actions for Perl running on Windows, Mac OSX, and Ubuntu Linux by Gabor Szabo
TODO: others?
This project's source code is hosted on GitHub.com.
Issues should be reported using the project's GitHub issue tracker.
Contributions are welcome. Please use GitHub Pull Requests.
To install BRIANG::Dist::Perfect, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BRIANG::Dist::Perfect
CPAN shell
perl -MCPAN -e shell install BRIANG::Dist::Perfect
For more information on module installation, please visit the detailed CPAN module installation guide.