File Coverage

blib/lib/Hydrogen/Topic/Scalar.pm
Criterion Covered Total %
statement 28 36 77.7
branch 2 10 20.0
condition n/a
subroutine 10 13 76.9
pod 5 5 100.0
total 45 64 70.3


line stmt bran cond sub pod time code
1             # This file was autogenerated.
2 2     2   216304 use 5.008001;
  2         8  
3 2     2   9 use strict;
  2         4  
  2         61  
4 2     2   9 use warnings;
  2         3  
  2         97  
5 2     2   8 no warnings qw( void once );
  2         6  
  2         91  
6 2     2   540 use Hydrogen ();
  2         4  
  2         139  
7              
8             package Hydrogen::Topic::Scalar;
9              
10             our $AUTHORITY = 'cpan:TOBYINK';
11             our $VERSION = '0.021001';
12              
13             =head1 NAME
14              
15             Hydrogen::Topic::Scalar - functions from Hydrogen::Scalar applied to C<$_>
16              
17             =head1 VERSION
18              
19             This documentation is for Hydrogen::Topic::Scalar 0.021001,
20             which is based on Sub::HandlesVia::HandlerLibrary::Scalar 0.050005.
21              
22             =cut
23              
24             =head1 FUNCTIONS
25              
26             Each function implicitly operates on C<< $_ >>, expecting it to be a scalar.
27              
28             =cut
29              
30 2         13 use Exporter::Shiny qw(
31             get
32             make_getter
33             make_setter
34             set
35             stringify
36 2     2   12 );
  2         4  
37              
38             =head2 C<< get() >>
39              
40             Operates on C<< $_ >>, which must be a scalar.
41              
42             Gets the current value of the scalar.
43              
44             =cut
45              
46             sub get {
47              
48             package Hydrogen::Scalar::__SANDBOX__;
49 0 0   0 1 0 @_ == 0
50             or Hydrogen::croak( "Wrong number of parameters for get; usage: "
51             . "Hydrogen::Topic::Scalar::get()" );
52 0         0 $_;
53             }
54              
55             =head2 C<< make_getter() >>
56              
57             Operates on C<< $_ >>, which must be a scalar.
58              
59             Returns a getter coderef.
60              
61             =cut
62              
63             sub make_getter {
64              
65             package Hydrogen::Scalar::__SANDBOX__;
66 1 50   1 1 315445 @_ == 0
67             or Hydrogen::croak( "Wrong number of parameters for make_getter; usage: "
68             . "Hydrogen::Topic::Scalar::make_getter()" );
69 1         3 my $s = $_;
70 1     1   7 sub { unshift @_, $s; $_ }
  1         8  
71 1         6 }
72              
73             =head2 C<< make_setter() >>
74              
75             Operates on C<< $_ >>, which must be a scalar.
76              
77             Returns a setter coderef.
78              
79             =cut
80              
81             sub make_setter {
82              
83             package Hydrogen::Scalar::__SANDBOX__;
84 1 50   1 1 4951 @_ == 0
85             or Hydrogen::croak( "Wrong number of parameters for make_setter; usage: "
86             . "Hydrogen::Topic::Scalar::make_setter()" );
87 1         2 my $s = $_;
88 1     1   4 sub { my $val = shift; unshift @_, $s; ( $_ = $val ) }
  1         2  
  1         3  
89 1         4 }
90              
91             =head2 C<< set( $value ) >>
92              
93             Operates on C<< $_ >>, which must be a scalar.
94              
95             Sets the scalar to a new value.
96              
97             =cut
98              
99             sub set {
100              
101             package Hydrogen::Scalar::__SANDBOX__;
102 0 0   0 1   @_ == 1
103             or Hydrogen::croak( "Wrong number of parameters for set; usage: "
104             . "Hydrogen::Topic::Scalar::set( \$value )" );
105 0           ( $_ = $_[0] );
106             }
107              
108             =head2 C<< stringify() >>
109              
110             Operates on C<< $_ >>, which must be a scalar.
111              
112             Gets the current value of the scalar, but as a string.
113              
114             =cut
115              
116             sub stringify {
117              
118             package Hydrogen::Scalar::__SANDBOX__;
119 0 0   0 1   @_ == 0
120             or Hydrogen::croak( "Wrong number of parameters for stringify; usage: "
121             . "Hydrogen::Topic::Scalar::stringify()" );
122 0           do { my $shv_tmp = $_; sprintf q(%s), $shv_tmp; }
  0            
  0            
123             }
124              
125             1;
126              
127             =head1 EXPORT
128              
129             No functions are exported by this module by default. To import them all (this is usually a bad idea), use:
130              
131             use Hydrogen::Topic::Scalar -all;
132              
133             To import a particular function, use:
134              
135             use Hydrogen::Topic::Scalar 'make_setter';
136              
137             To rename functions:
138              
139             use Hydrogen::Topic::Scalar 'make_setter' => { -as => 'myfunc' };
140              
141             On Perl 5.37.2+ (or if L is installed) you can import lexically:
142              
143             use Hydrogen::Topic::Scalar -lexical, 'make_setter';
144              
145             See L for more hints on importing.
146              
147             =head1 BUGS
148              
149             Please report any bugs to
150             L.
151              
152             =head1 SEE ALSO
153              
154             L,
155             L,
156             L,
157             L.
158              
159             =head1 AUTHOR
160              
161             Toby Inkster Etobyink@cpan.orgE.
162              
163             =head1 COPYRIGHT AND LICENCE
164              
165             This software is copyright (c) 2022-2025 by Toby Inkster.
166              
167             This is free software; you can redistribute it and/or modify it under
168             the same terms as the Perl 5 programming language system itself.
169              
170             =head1 DISCLAIMER OF WARRANTIES
171              
172             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
173             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
174             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
175