Acme-Free-Advice

 view release on metacpan or  search on metacpan

lib/Acme/Free/Advice.pm  view on Meta::CPAN

package Acme::Free::Advice 1.1 {
    use v5.38;
    use parent 'Exporter';
    use Module::Load;
    our %EXPORT_TAGS = ( all => [ our @EXPORT_OK = qw[advice flavors] ] );
    #
    my %flavor = (
        map {
            my $pkg = 'Acme::Free::Advice::' . $_;
            ( eval 'require ' . $pkg ? ( lc($_) => $pkg ) : () ),
        } qw[Slip Unsolicited]
    );

    sub advice ( $flavor //= ( keys %flavor )[ rand keys %flavor ] ) {
        $flavor{$flavor} // return ();
        my $cv = $flavor{$flavor}->can('advice');
        $cv ? $cv->() : ();
    }
    sub flavors () { keys %flavor }
}
1;
__END__

=encoding utf-8

=head1 NAME

Acme::Free::Advice - Wise words. Dumb code.

=head1 SYNOPSIS

    use Acme::Free::Advice qw[advice];
    say advice;

=head1 DESCRIPTION

Acme::Free::Advice spits out advice. Good advice. Bad advice. Advice. It's a fortune cookie.

=head1 METHODS

These functions may be imported by name or with the C<:all> tag.

=head2 C<advice( [...] )>

Tear someone down.

    my $wisdom = advice( ); # Random advice
    print advice( ); # stringify
    print advice( 'slip' );

Expected parameters include:

=over

=item C<flavor>

If undefined, a random supported flavor is used.

Currently, supported flavors include:

=over

=item C<slip>

Uses L<Acme::Free::Advice::Slip>

=item C<unsolicited>



( run in 1.790 second using v1.01-cache-2.11-cpan-140bd7fdf52 )