| 1 | |||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package Zest::Author::TABULO::Util::Mayhap; | ||||||||||||||||||||
| 6 | 2 | our $VERSION = '1.000014'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 2 | ▶ | use PerlX::Maybe qw(maybe); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 2 | ▶ | use Exporter::Shiny qw(mayhap); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | #region: #== UTILITY FUNCTIONS (EXPORT_OK) == | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | ## no critic: Prototypes | ||||||||||||||||||||
| 15 | 13 | ▶ | sub mayhap ($$@) { # the prototype is intentional here. | ||||||||||||||||||
|
Subroutine
mayhap: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 16 | 13 | my ( $arg1, $arg2 ) = ( shift, shift ); | |||||||||||||||||||
| 17 | 13 | maybe $arg1 => _undef_if_empty($arg2), @_; | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 13 | ▶ | sub _undef_if_empty { # Utility function | ||||||||||||||||||
|
Subroutine
_undef_if_empty: called CC=7 SCAR=21.8
| |||||||||||||||||||||
| 21 | 13 | my $x = shift; | |||||||||||||||||||
| 22 | 13 | ▶ | for ( ref $x // () ) { | ||||||||||||||||||
|
Condition33%1/3
ref $x // ()
MC/DC0%0/2
ref $x // ()
ref $x
()
Truth table33%1/3
A // B
A= ref $xB= ()
| |||||||||||||||||||||
| 23 | 13 | ▶ | m/ARRAY/ and do { return ( @$x ? $x : undef ) }; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 24 | 0 | ▶ | m/HASH/ and do { return ( %$x ? $x : undef ) }; | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | 6 | $x; | |||||||||||||||||||
| 27 | } | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | #endregion (UTILITY FUNCTIONS) | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 2 | 1; | |||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | =pod | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | =encoding UTF-8 | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | =for :stopwords Tabulo[n] | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | =head1 NAME | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | Zest::Author::TABULO::Util::Mayhap - Utility functions used by TABULO's authoring dist | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | =head1 VERSION | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | version 1.000014 | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =for Pod::Coverage mayhap | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head1 AUTHORS | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | Tabulo[n] <dev@tabulo.net> | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | =head1 LEGAL | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | This software is copyright (c) 2023 by Tabulo[n]. | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 58 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | __END__ | ||||||||||||||||||||