File Coverage

blib/lib/Hydrogen/Topic/CodeRef.pm
Criterion Covered Total %
statement 23 23 100.0
branch 1 2 50.0
condition n/a
subroutine 10 10 100.0
pod 4 4 100.0
total 38 39 97.4


line stmt bran cond sub pod time code
1             # This file was autogenerated.
2 2     2   229937 use 5.008001;
  2         12  
3 2     2   13 use strict;
  2         3  
  2         39  
4 2     2   8 use warnings;
  2         4  
  2         52  
5 2     2   9 no warnings qw( void once );
  2         5  
  2         54  
6 2     2   414 use Hydrogen ();
  2         5  
  2         137  
7              
8             package Hydrogen::Topic::CodeRef;
9              
10             our $AUTHORITY = 'cpan:TOBYINK';
11             our $VERSION = '0.020000';
12              
13             =head1 NAME
14              
15             Hydrogen::Topic::CodeRef - functions from Hydrogen::CodeRef applied to C<$_>
16              
17             =head1 VERSION
18              
19             This documentation is for Hydrogen::Topic::CodeRef 0.020000,
20             which is based on Sub::HandlesVia::HandlerLibrary::Code 0.046.
21              
22             =cut
23              
24             =head1 FUNCTIONS
25              
26             Each function implicitly operates on C<< $_ >>, expecting it to be a reference to a sub.
27              
28             =cut
29              
30 2         16 use Exporter::Shiny qw(
31             execute
32             execute_list
33             execute_scalar
34             execute_void
35 2     2   13 );
  2         3  
36              
37             =head2 C<< execute( @args ) >>
38              
39             Operates on C<< $_ >>, which must be a reference to a sub.
40              
41             Calls the coderef, passing it any arguments.
42              
43             =cut
44              
45             sub execute {
46              
47             package Hydrogen::CodeRef::__SANDBOX__;
48 1     1 1 8135 $_->(@_);
49             }
50              
51             =head2 C<< execute_list( @args ) >>
52              
53             Operates on C<< $_ >>, which must be a reference to a sub.
54              
55             Calls the coderef, passing it any arguments, and forcing list context. If called in scalar context, returns an arrayref.
56              
57             =cut
58              
59             sub execute_list {
60              
61             package Hydrogen::CodeRef::__SANDBOX__;
62 1     1 1 3513 my @shv_list = $_->(@_);
63 1 50       12 wantarray ? @shv_list : \@shv_list;
64             }
65              
66             =head2 C<< execute_scalar( @args ) >>
67              
68             Operates on C<< $_ >>, which must be a reference to a sub.
69              
70             Calls the coderef, passing it any arguments, and forcing scalar context.
71              
72             =cut
73              
74             sub execute_scalar {
75              
76             package Hydrogen::CodeRef::__SANDBOX__;
77 1     1 1 4930 scalar( $_->(@_) );
78             }
79              
80             =head2 C<< execute_void( @args ) >>
81              
82             Operates on C<< $_ >>, which must be a reference to a sub.
83              
84             Calls the coderef, passing it any arguments, and forcing void context. Returns undef.
85              
86             =cut
87              
88             sub execute_void {
89              
90             package Hydrogen::CodeRef::__SANDBOX__;
91 1     1 1 3917 $_->(@_);
92 1         4 undef;
93             }
94              
95             1;
96              
97             =head1 EXPORT
98              
99             No functions are exported by this module by default. To import them all (this is usually a bad idea), use:
100              
101             use Hydrogen::Topic::CodeRef -all;
102              
103             To import a particular function, use:
104              
105             use Hydrogen::Topic::CodeRef 'execute_scalar';
106              
107             To rename functions:
108              
109             use Hydrogen::Topic::CodeRef 'execute_scalar' => { -as => 'myfunc' };
110              
111             On Perl 5.37.2+ (or if L is installed) you can import lexically:
112              
113             use Hydrogen::Topic::CodeRef -lexical, 'execute_scalar';
114              
115             See L for more hints on importing.
116              
117             =head1 BUGS
118              
119             Please report any bugs to
120             L.
121              
122             =head1 SEE ALSO
123              
124             L,
125             L,
126             L,
127             L,
128             L,
129             L.
130              
131             =head1 AUTHOR
132              
133             Toby Inkster Etobyink@cpan.orgE.
134              
135             =head1 COPYRIGHT AND LICENCE
136              
137             This software is copyright (c) 2022-2023 by Toby Inkster.
138              
139             This is free software; you can redistribute it and/or modify it under
140             the same terms as the Perl 5 programming language system itself.
141              
142             =head1 DISCLAIMER OF WARRANTIES
143              
144             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
145             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
146             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
147