The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

BRIANG::Dist::Perfect - A perfect distribution for a perfect year. Or perhaps not.

VERSION

This is version 0.0101 released 2020-11-21

SYNOPSIS

    # 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

DESCRIPTION

This module is the principal component from the BRIANG::Dist::Perfect distribution.

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.

EXPORTS

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.

FUNCTIONS

bump

    $next_counter_value = bump()

Increases the counter by one and returns the new value.

Exceptions Thrown

Six encountered

    Thrown whenever bump() would normally have returned the value 6.

set

    set($initial_value)

Initialises the counter to $initial_value, or zero if $initial_value is omitted.

Exceptions Thrown

Six encountered

    Thrown whenever set() is called with $initial_value >= 6.

view

    $counter_value = view()

CONSTRUCTOR

new

    $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.

METHODS

counter

    $next_counter_value = $counter->count()

Adds one to the counter and returns the new value.

peek

    $counter_value = $counter->peek()

Returns the value of the counter without incrementing its value.

AUTHOR, COPYRIGHT AND LICENSE

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.

SEE ALSO

CPAN::Meta::Spec

ExtUtils::MakeMaker

Release::Checklist

Github Actions for Perl running on Windows, Mac OSX, and Ubuntu Linux by Gabor Szabo

TODO: others?

CODE REPOSITORY AND ISSUE REPORTING

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.

TODO: more pod???