File Coverage

blib/lib/Hydrogen/Topic/String.pm
Criterion Covered Total %
statement 160 377 42.4
branch 72 342 21.0
condition 2 36 5.5
subroutine 24 54 44.4
pod 39 39 100.0
total 297 848 35.0


line stmt bran cond sub pod time code
1             # This file was autogenerated.
2 4     4   749172 use 5.008001;
  4         16  
3 4     4   24 use strict;
  4         9  
  4         117  
4 4     4   21 use warnings;
  4         8  
  4         228  
5 4     4   24 no warnings qw( void once );
  4         10  
  4         185  
6 4     4   1565 use Hydrogen ();
  4         13  
  4         457  
7              
8             package Hydrogen::Topic::String;
9              
10             our $AUTHORITY = 'cpan:TOBYINK';
11             our $VERSION = '0.021001';
12              
13             =head1 NAME
14              
15             Hydrogen::Topic::String - functions from Hydrogen::String applied to C<$_>
16              
17             =head1 VERSION
18              
19             This documentation is for Hydrogen::Topic::String 0.021001,
20             which is based on Sub::HandlesVia::HandlerLibrary::String 0.050005.
21              
22             =cut
23              
24             =head1 FUNCTIONS
25              
26             Each function implicitly operates on C<< $_ >>, expecting it to be a string scalar.
27              
28             =cut
29              
30 4         24 use Exporter::Shiny qw(
31             append
32             chomp
33             chop
34             clear
35             cmp
36             cmpi
37             contains
38             contains_i
39             ends_with
40             ends_with_i
41             eq
42             eqi
43             fc
44             ge
45             gei
46             get
47             gt
48             gti
49             inc
50             lc
51             le
52             lei
53             length
54             lt
55             lti
56             match
57             match_i
58             ne
59             nei
60             prepend
61             replace
62             replace_globally
63             reset
64             set
65             starts_with
66             starts_with_i
67             substr
68             trim
69             uc
70 4     4   33 );
  4         9  
71              
72             =head2 C<< append( $tail ) >>
73              
74             Operates on C<< $_ >>, which must be a string scalar.
75              
76             Arguments: B<< Str >>.
77              
78             Appends another string to the end of the current string and updates the original value.
79              
80             =cut
81              
82             sub append {
83              
84             package Hydrogen::String::__SANDBOX__;
85 7     7 1 988424 @_ = do {
86 7         14 my ( %tmp, $tmp );
87              
88 7 50       24 @_ == 1
89             or Hydrogen::croak(
90             "Wrong number of parameters in signature for %s: got %d, %s",
91             "append", scalar(@_), "expected exactly 1 parameters" );
92              
93             # Parameter $_[0] (type: Str)
94 7 50       13 do {
95              
96             package Hydrogen::String::__SANDBOX__;
97 7 50       25 defined( $_[0] ) and do {
98 7 50       42 ref( \$_[0] ) eq 'SCALAR'
99             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
100             }
101             }
102             or Hydrogen::croak(
103             "Type check failed in signature for append: %s should be %s",
104             "\$_[0]", "Str" );
105              
106 7         23 (@_);
107             };
108             (
109 7         15 $_ = do {
110 7         17 my $shv_final_unchecked = $_ . $_[0];
111 7         12 do {
112 7 50       12 do {
113              
114             package Hydrogen::String::__SANDBOX__;
115 7 50       26 defined($shv_final_unchecked) and do {
116 7 50       49 ref( \$shv_final_unchecked ) eq 'SCALAR'
117             or ref( \( my $val = $shv_final_unchecked ) ) eq
118             'SCALAR';
119             }
120             }
121             or Hydrogen::croak(
122             "Type check failed for append: expected %s, got value %s",
123             "Str", $shv_final_unchecked );
124 7         65 $shv_final_unchecked;
125             };
126             }
127             );
128             }
129              
130             =head2 C<< chomp() >>
131              
132             Operates on C<< $_ >>, which must be a string scalar.
133              
134             Like C from L.
135              
136             =cut
137              
138             sub chomp {
139              
140             package Hydrogen::String::__SANDBOX__;
141 0 0   0 1 0 @_ == 0
142             or Hydrogen::croak( "Wrong number of parameters for chomp; usage: "
143             . "Hydrogen::Topic::String::chomp()" );
144 0         0 1;
145 0         0 chomp($_);
146             }
147              
148             =head2 C<< chop() >>
149              
150             Operates on C<< $_ >>, which must be a string scalar.
151              
152             Like C from L.
153              
154             =cut
155              
156             sub chop {
157              
158             package Hydrogen::String::__SANDBOX__;
159 0 0   0 1 0 @_ == 0
160             or Hydrogen::croak( "Wrong number of parameters for chop; usage: "
161             . "Hydrogen::Topic::String::chop()" );
162 0         0 1;
163 0         0 chop($_);
164             }
165              
166             =head2 C<< clear() >>
167              
168             Operates on C<< $_ >>, which must be a string scalar.
169              
170             Sets the string to the empty string.
171              
172             =cut
173              
174             sub clear {
175              
176             package Hydrogen::String::__SANDBOX__;
177 1 50   1 1 9230 @_ == 0
178             or Hydrogen::croak( "Wrong number of parameters for clear; usage: "
179             . "Hydrogen::Topic::String::clear()" );
180 1         2 1;
181 1         4 ( $_ = q() );
182             }
183              
184             =head2 C<< cmp( $str ) >>
185              
186             Operates on C<< $_ >>, which must be a string scalar.
187              
188             Arguments: B<< Str >>.
189              
190             Returns C<< $_ cmp $str >>.
191              
192             =cut
193              
194             sub cmp {
195              
196             package Hydrogen::String::__SANDBOX__;
197 0     0 1 0 @_ = do {
198 0         0 my ( %tmp, $tmp );
199              
200 0 0       0 @_ == 1
201             or Hydrogen::croak(
202             "Wrong number of parameters in signature for %s: got %d, %s",
203             "cmp", scalar(@_), "expected exactly 1 parameters" );
204              
205             # Parameter $_[0] (type: Str)
206 0 0       0 do {
207              
208             package Hydrogen::String::__SANDBOX__;
209 0 0       0 defined( $_[0] ) and do {
210 0 0       0 ref( \$_[0] ) eq 'SCALAR'
211             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
212             }
213             }
214             or Hydrogen::croak(
215             "Type check failed in signature for cmp: %s should be %s",
216             "\$_[0]", "Str" );
217              
218 0         0 (@_);
219             };
220 0         0 $_ cmp $_[0];
221             }
222              
223             =head2 C<< cmpi( $str ) >>
224              
225             Operates on C<< $_ >>, which must be a string scalar.
226              
227             Arguments: B<< Str >>.
228              
229             Returns C<< fc($_) cmp fc($str) >>. Uses C instead of C in versions of Perl older than 5.16.
230              
231             =cut
232              
233             sub cmpi {
234              
235             package Hydrogen::String::__SANDBOX__;
236 0     0 1 0 @_ = do {
237 0         0 my ( %tmp, $tmp );
238              
239 0 0       0 @_ == 1
240             or Hydrogen::croak(
241             "Wrong number of parameters in signature for %s: got %d, %s",
242             "cmpi", scalar(@_), "expected exactly 1 parameters" );
243              
244             # Parameter $_[0] (type: Str)
245 0 0       0 do {
246              
247             package Hydrogen::String::__SANDBOX__;
248 0 0       0 defined( $_[0] ) and do {
249 0 0       0 ref( \$_[0] ) eq 'SCALAR'
250             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
251             }
252             }
253             or Hydrogen::croak(
254             "Type check failed in signature for cmpi: %s should be %s",
255             "\$_[0]", "Str" );
256              
257 0         0 (@_);
258             };
259 0         0 Hydrogen::fc($_) cmp Hydrogen::fc( $_[0] );
260             }
261              
262             =head2 C<< contains( $str ) >>
263              
264             Operates on C<< $_ >>, which must be a string scalar.
265              
266             Arguments: B<< Str >>.
267              
268             Returns true iff the string contains C<< $str >>.
269              
270             =cut
271              
272             sub contains {
273              
274             package Hydrogen::String::__SANDBOX__;
275 0     0 1 0 @_ = do {
276 0         0 my ( %tmp, $tmp );
277              
278 0 0       0 @_ == 1
279             or Hydrogen::croak(
280             "Wrong number of parameters in signature for %s: got %d, %s",
281             "contains", scalar(@_), "expected exactly 1 parameters" );
282              
283             # Parameter $_[0] (type: Str)
284 0 0       0 do {
285              
286             package Hydrogen::String::__SANDBOX__;
287 0 0       0 defined( $_[0] ) and do {
288 0 0       0 ref( \$_[0] ) eq 'SCALAR'
289             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
290             }
291             }
292             or Hydrogen::croak(
293             "Type check failed in signature for contains: %s should be %s",
294             "\$_[0]", "Str" );
295              
296 0         0 (@_);
297             };
298 0         0 index( $_, $_[0] ) != -1;
299             }
300              
301             =head2 C<< contains_i( $str ) >>
302              
303             Operates on C<< $_ >>, which must be a string scalar.
304              
305             Arguments: B<< Str >>.
306              
307             Returns true iff the string contains C<< $str >> case-insensitvely.
308              
309             =cut
310              
311             sub contains_i {
312              
313             package Hydrogen::String::__SANDBOX__;
314 0     0 1 0 @_ = do {
315 0         0 my ( %tmp, $tmp );
316              
317 0 0       0 @_ == 1
318             or Hydrogen::croak(
319             "Wrong number of parameters in signature for %s: got %d, %s",
320             "contains_i", scalar(@_), "expected exactly 1 parameters" );
321              
322             # Parameter $_[0] (type: Str)
323 0 0       0 do {
324              
325             package Hydrogen::String::__SANDBOX__;
326 0 0       0 defined( $_[0] ) and do {
327 0 0       0 ref( \$_[0] ) eq 'SCALAR'
328             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
329             }
330             }
331             or Hydrogen::croak(
332             "Type check failed in signature for contains_i: %s should be %s",
333             "\$_[0]", "Str" );
334              
335 0         0 (@_);
336             };
337 0         0 index( Hydrogen::fc($_), Hydrogen::fc( $_[0] ) ) != -1;
338             }
339              
340             =head2 C<< ends_with( $tail ) >>
341              
342             Operates on C<< $_ >>, which must be a string scalar.
343              
344             Arguments: B<< Str >>.
345              
346             Returns true iff the string ends with C<< $tail >>.
347              
348             =cut
349              
350             sub ends_with {
351              
352             package Hydrogen::String::__SANDBOX__;
353 0     0 1 0 @_ = do {
354 0         0 my ( %tmp, $tmp );
355              
356 0 0       0 @_ == 1
357             or Hydrogen::croak(
358             "Wrong number of parameters in signature for %s: got %d, %s",
359             "ends_with", scalar(@_), "expected exactly 1 parameters" );
360              
361             # Parameter $_[0] (type: Str)
362 0 0       0 do {
363              
364             package Hydrogen::String::__SANDBOX__;
365 0 0       0 defined( $_[0] ) and do {
366 0 0       0 ref( \$_[0] ) eq 'SCALAR'
367             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
368             }
369             }
370             or Hydrogen::croak(
371             "Type check failed in signature for ends_with: %s should be %s",
372             "\$_[0]", "Str" );
373              
374 0         0 (@_);
375             };
376 0         0 substr( $_, -length $_[0] ) eq $_[0];
377             }
378              
379             =head2 C<< ends_with_i( $tail ) >>
380              
381             Operates on C<< $_ >>, which must be a string scalar.
382              
383             Arguments: B<< Str >>.
384              
385             Returns true iff the string ends with C<< $tail >> case-insensitvely.
386              
387             =cut
388              
389             sub ends_with_i {
390              
391             package Hydrogen::String::__SANDBOX__;
392 0     0 1 0 @_ = do {
393 0         0 my ( %tmp, $tmp );
394              
395 0 0       0 @_ == 1
396             or Hydrogen::croak(
397             "Wrong number of parameters in signature for %s: got %d, %s",
398             "ends_with_i", scalar(@_), "expected exactly 1 parameters" );
399              
400             # Parameter $_[0] (type: Str)
401 0 0       0 do {
402              
403             package Hydrogen::String::__SANDBOX__;
404 0 0       0 defined( $_[0] ) and do {
405 0 0       0 ref( \$_[0] ) eq 'SCALAR'
406             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
407             }
408             }
409             or Hydrogen::croak(
410             "Type check failed in signature for ends_with_i: %s should be %s",
411             "\$_[0]", "Str" );
412              
413 0         0 (@_);
414             };
415 0         0 Hydrogen::fc( substr( $_, -length $_[0] ) ) eq Hydrogen::fc( $_[0] );
416             }
417              
418             =head2 C<< eq( $str ) >>
419              
420             Operates on C<< $_ >>, which must be a string scalar.
421              
422             Arguments: B<< Str >>.
423              
424             Returns C<< $_ eq $str >>.
425              
426             =cut
427              
428             sub eq {
429              
430             package Hydrogen::String::__SANDBOX__;
431 0     0 1 0 @_ = do {
432 0         0 my ( %tmp, $tmp );
433              
434 0 0       0 @_ == 1
435             or Hydrogen::croak(
436             "Wrong number of parameters in signature for %s: got %d, %s",
437             "eq", scalar(@_), "expected exactly 1 parameters" );
438              
439             # Parameter $_[0] (type: Str)
440 0 0       0 do {
441              
442             package Hydrogen::String::__SANDBOX__;
443 0 0       0 defined( $_[0] ) and do {
444 0 0       0 ref( \$_[0] ) eq 'SCALAR'
445             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
446             }
447             }
448             or Hydrogen::croak(
449             "Type check failed in signature for eq: %s should be %s",
450             "\$_[0]", "Str" );
451              
452 0         0 (@_);
453             };
454 0         0 $_ eq $_[0];
455             }
456              
457             =head2 C<< eqi( $str ) >>
458              
459             Operates on C<< $_ >>, which must be a string scalar.
460              
461             Arguments: B<< Str >>.
462              
463             Returns C<< fc($_) eq fc($str) >>. Uses C instead of C in versions of Perl older than 5.16.
464              
465             =cut
466              
467             sub eqi {
468              
469             package Hydrogen::String::__SANDBOX__;
470 0     0 1 0 @_ = do {
471 0         0 my ( %tmp, $tmp );
472              
473 0 0       0 @_ == 1
474             or Hydrogen::croak(
475             "Wrong number of parameters in signature for %s: got %d, %s",
476             "eqi", scalar(@_), "expected exactly 1 parameters" );
477              
478             # Parameter $_[0] (type: Str)
479 0 0       0 do {
480              
481             package Hydrogen::String::__SANDBOX__;
482 0 0       0 defined( $_[0] ) and do {
483 0 0       0 ref( \$_[0] ) eq 'SCALAR'
484             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
485             }
486             }
487             or Hydrogen::croak(
488             "Type check failed in signature for eqi: %s should be %s",
489             "\$_[0]", "Str" );
490              
491 0         0 (@_);
492             };
493 0         0 Hydrogen::fc($_) eq Hydrogen::fc( $_[0] );
494             }
495              
496             =head2 C<< fc() >>
497              
498             Operates on C<< $_ >>, which must be a string scalar.
499              
500             Returns C<< fc($_) >>.
501              
502             =cut
503              
504             sub fc {
505              
506             package Hydrogen::String::__SANDBOX__;
507 0 0   0 1 0 @_ == 0
508             or Hydrogen::croak( "Wrong number of parameters for fc; usage: "
509             . "Hydrogen::Topic::String::fc()" );
510 0         0 Hydrogen::fc($_);
511             }
512              
513             =head2 C<< ge( $str ) >>
514              
515             Operates on C<< $_ >>, which must be a string scalar.
516              
517             Arguments: B<< Str >>.
518              
519             Returns C<< $_ ge $str >>.
520              
521             =cut
522              
523             sub ge {
524              
525             package Hydrogen::String::__SANDBOX__;
526 0     0 1 0 @_ = do {
527 0         0 my ( %tmp, $tmp );
528              
529 0 0       0 @_ == 1
530             or Hydrogen::croak(
531             "Wrong number of parameters in signature for %s: got %d, %s",
532             "ge", scalar(@_), "expected exactly 1 parameters" );
533              
534             # Parameter $_[0] (type: Str)
535 0 0       0 do {
536              
537             package Hydrogen::String::__SANDBOX__;
538 0 0       0 defined( $_[0] ) and do {
539 0 0       0 ref( \$_[0] ) eq 'SCALAR'
540             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
541             }
542             }
543             or Hydrogen::croak(
544             "Type check failed in signature for ge: %s should be %s",
545             "\$_[0]", "Str" );
546              
547 0         0 (@_);
548             };
549 0         0 $_ ge $_[0];
550             }
551              
552             =head2 C<< gei( $str ) >>
553              
554             Operates on C<< $_ >>, which must be a string scalar.
555              
556             Arguments: B<< Str >>.
557              
558             Returns C<< fc($_) ge fc($str) >>. Uses C instead of C in versions of Perl older than 5.16.
559              
560             =cut
561              
562             sub gei {
563              
564             package Hydrogen::String::__SANDBOX__;
565 0     0 1 0 @_ = do {
566 0         0 my ( %tmp, $tmp );
567              
568 0 0       0 @_ == 1
569             or Hydrogen::croak(
570             "Wrong number of parameters in signature for %s: got %d, %s",
571             "gei", scalar(@_), "expected exactly 1 parameters" );
572              
573             # Parameter $_[0] (type: Str)
574 0 0       0 do {
575              
576             package Hydrogen::String::__SANDBOX__;
577 0 0       0 defined( $_[0] ) and do {
578 0 0       0 ref( \$_[0] ) eq 'SCALAR'
579             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
580             }
581             }
582             or Hydrogen::croak(
583             "Type check failed in signature for gei: %s should be %s",
584             "\$_[0]", "Str" );
585              
586 0         0 (@_);
587             };
588 0         0 Hydrogen::fc($_) ge Hydrogen::fc( $_[0] );
589             }
590              
591             =head2 C<< get() >>
592              
593             Operates on C<< $_ >>, which must be a string scalar.
594              
595             Gets the current value of the string.
596              
597             =cut
598              
599             sub get {
600              
601             package Hydrogen::String::__SANDBOX__;
602 1 50   1 1 30129 @_ == 0
603             or Hydrogen::croak( "Wrong number of parameters for get; usage: "
604             . "Hydrogen::Topic::String::get()" );
605 1         8 $_;
606             }
607              
608             =head2 C<< gt( $str ) >>
609              
610             Operates on C<< $_ >>, which must be a string scalar.
611              
612             Arguments: B<< Str >>.
613              
614             Returns C<< $_ gt $str >>.
615              
616             =cut
617              
618             sub gt {
619              
620             package Hydrogen::String::__SANDBOX__;
621 0     0 1 0 @_ = do {
622 0         0 my ( %tmp, $tmp );
623              
624 0 0       0 @_ == 1
625             or Hydrogen::croak(
626             "Wrong number of parameters in signature for %s: got %d, %s",
627             "gt", scalar(@_), "expected exactly 1 parameters" );
628              
629             # Parameter $_[0] (type: Str)
630 0 0       0 do {
631              
632             package Hydrogen::String::__SANDBOX__;
633 0 0       0 defined( $_[0] ) and do {
634 0 0       0 ref( \$_[0] ) eq 'SCALAR'
635             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
636             }
637             }
638             or Hydrogen::croak(
639             "Type check failed in signature for gt: %s should be %s",
640             "\$_[0]", "Str" );
641              
642 0         0 (@_);
643             };
644 0         0 $_ gt $_[0];
645             }
646              
647             =head2 C<< gti( $str ) >>
648              
649             Operates on C<< $_ >>, which must be a string scalar.
650              
651             Arguments: B<< Str >>.
652              
653             Returns C<< fc($_) gt fc($str) >>. Uses C instead of C in versions of Perl older than 5.16.
654              
655             =cut
656              
657             sub gti {
658              
659             package Hydrogen::String::__SANDBOX__;
660 0     0 1 0 @_ = do {
661 0         0 my ( %tmp, $tmp );
662              
663 0 0       0 @_ == 1
664             or Hydrogen::croak(
665             "Wrong number of parameters in signature for %s: got %d, %s",
666             "gti", scalar(@_), "expected exactly 1 parameters" );
667              
668             # Parameter $_[0] (type: Str)
669 0 0       0 do {
670              
671             package Hydrogen::String::__SANDBOX__;
672 0 0       0 defined( $_[0] ) and do {
673 0 0       0 ref( \$_[0] ) eq 'SCALAR'
674             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
675             }
676             }
677             or Hydrogen::croak(
678             "Type check failed in signature for gti: %s should be %s",
679             "\$_[0]", "Str" );
680              
681 0         0 (@_);
682             };
683 0         0 Hydrogen::fc($_) gt Hydrogen::fc( $_[0] );
684             }
685              
686             =head2 C<< inc() >>
687              
688             Operates on C<< $_ >>, which must be a string scalar.
689              
690             Performs C<< ++ >> on the string.
691              
692             =cut
693              
694             sub inc {
695              
696             package Hydrogen::String::__SANDBOX__;
697 0 0   0 1 0 @_ == 0
698             or Hydrogen::croak( "Wrong number of parameters for inc; usage: "
699             . "Hydrogen::Topic::String::inc()" );
700 0         0 1;
701 0         0 ++$_;
702             }
703              
704             =head2 C<< lc() >>
705              
706             Operates on C<< $_ >>, which must be a string scalar.
707              
708             Returns C<< lc($_) >>.
709              
710             =cut
711              
712             sub lc {
713              
714             package Hydrogen::String::__SANDBOX__;
715 0 0   0 1 0 @_ == 0
716             or Hydrogen::croak( "Wrong number of parameters for lc; usage: "
717             . "Hydrogen::Topic::String::lc()" );
718 0         0 lc($_);
719             }
720              
721             =head2 C<< le( $str ) >>
722              
723             Operates on C<< $_ >>, which must be a string scalar.
724              
725             Arguments: B<< Str >>.
726              
727             Returns C<< $_ le $str >>.
728              
729             =cut
730              
731             sub le {
732              
733             package Hydrogen::String::__SANDBOX__;
734 0     0 1 0 @_ = do {
735 0         0 my ( %tmp, $tmp );
736              
737 0 0       0 @_ == 1
738             or Hydrogen::croak(
739             "Wrong number of parameters in signature for %s: got %d, %s",
740             "le", scalar(@_), "expected exactly 1 parameters" );
741              
742             # Parameter $_[0] (type: Str)
743 0 0       0 do {
744              
745             package Hydrogen::String::__SANDBOX__;
746 0 0       0 defined( $_[0] ) and do {
747 0 0       0 ref( \$_[0] ) eq 'SCALAR'
748             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
749             }
750             }
751             or Hydrogen::croak(
752             "Type check failed in signature for le: %s should be %s",
753             "\$_[0]", "Str" );
754              
755 0         0 (@_);
756             };
757 0         0 $_ le $_[0];
758             }
759              
760             =head2 C<< lei( $str ) >>
761              
762             Operates on C<< $_ >>, which must be a string scalar.
763              
764             Arguments: B<< Str >>.
765              
766             Returns C<< fc($_) le fc($str) >>. Uses C instead of C in versions of Perl older than 5.16.
767              
768             =cut
769              
770             sub lei {
771              
772             package Hydrogen::String::__SANDBOX__;
773 0     0 1 0 @_ = do {
774 0         0 my ( %tmp, $tmp );
775              
776 0 0       0 @_ == 1
777             or Hydrogen::croak(
778             "Wrong number of parameters in signature for %s: got %d, %s",
779             "lei", scalar(@_), "expected exactly 1 parameters" );
780              
781             # Parameter $_[0] (type: Str)
782 0 0       0 do {
783              
784             package Hydrogen::String::__SANDBOX__;
785 0 0       0 defined( $_[0] ) and do {
786 0 0       0 ref( \$_[0] ) eq 'SCALAR'
787             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
788             }
789             }
790             or Hydrogen::croak(
791             "Type check failed in signature for lei: %s should be %s",
792             "\$_[0]", "Str" );
793              
794 0         0 (@_);
795             };
796 0         0 Hydrogen::fc($_) le Hydrogen::fc( $_[0] );
797             }
798              
799             =head2 C<< length() >>
800              
801             Operates on C<< $_ >>, which must be a string scalar.
802              
803             Like C from L.
804              
805             =cut
806              
807             sub length {
808              
809             package Hydrogen::String::__SANDBOX__;
810 1 50   1 1 18231 @_ == 0
811             or Hydrogen::croak( "Wrong number of parameters for length; usage: "
812             . "Hydrogen::Topic::String::length()" );
813 1         8 length($_);
814             }
815              
816             =head2 C<< lt( $str ) >>
817              
818             Operates on C<< $_ >>, which must be a string scalar.
819              
820             Arguments: B<< Str >>.
821              
822             Returns C<< $_ lt $str >>.
823              
824             =cut
825              
826             sub lt {
827              
828             package Hydrogen::String::__SANDBOX__;
829 0     0 1 0 @_ = do {
830 0         0 my ( %tmp, $tmp );
831              
832 0 0       0 @_ == 1
833             or Hydrogen::croak(
834             "Wrong number of parameters in signature for %s: got %d, %s",
835             "lt", scalar(@_), "expected exactly 1 parameters" );
836              
837             # Parameter $_[0] (type: Str)
838 0 0       0 do {
839              
840             package Hydrogen::String::__SANDBOX__;
841 0 0       0 defined( $_[0] ) and do {
842 0 0       0 ref( \$_[0] ) eq 'SCALAR'
843             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
844             }
845             }
846             or Hydrogen::croak(
847             "Type check failed in signature for lt: %s should be %s",
848             "\$_[0]", "Str" );
849              
850 0         0 (@_);
851             };
852 0         0 $_ lt $_[0];
853             }
854              
855             =head2 C<< lti( $str ) >>
856              
857             Operates on C<< $_ >>, which must be a string scalar.
858              
859             Arguments: B<< Str >>.
860              
861             Returns C<< fc($_) lt fc($str) >>. Uses C instead of C in versions of Perl older than 5.16.
862              
863             =cut
864              
865             sub lti {
866              
867             package Hydrogen::String::__SANDBOX__;
868 0     0 1 0 @_ = do {
869 0         0 my ( %tmp, $tmp );
870              
871 0 0       0 @_ == 1
872             or Hydrogen::croak(
873             "Wrong number of parameters in signature for %s: got %d, %s",
874             "lti", scalar(@_), "expected exactly 1 parameters" );
875              
876             # Parameter $_[0] (type: Str)
877 0 0       0 do {
878              
879             package Hydrogen::String::__SANDBOX__;
880 0 0       0 defined( $_[0] ) and do {
881 0 0       0 ref( \$_[0] ) eq 'SCALAR'
882             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
883             }
884             }
885             or Hydrogen::croak(
886             "Type check failed in signature for lti: %s should be %s",
887             "\$_[0]", "Str" );
888              
889 0         0 (@_);
890             };
891 0         0 Hydrogen::fc($_) lt Hydrogen::fc( $_[0] );
892             }
893              
894             =head2 C<< match( $regexp ) >>
895              
896             Operates on C<< $_ >>, which must be a string scalar.
897              
898             Arguments: B<< Str|RegexpRef >>.
899              
900             Returns true iff the string matches the regexp.
901              
902             =cut
903              
904             sub match {
905              
906             package Hydrogen::String::__SANDBOX__;
907 1     1 1 8653 @_ = do {
908 1         3 my ( %tmp, $tmp );
909              
910 1 50       6 @_ == 1
911             or Hydrogen::croak(
912             "Wrong number of parameters in signature for %s: got %d, %s",
913             "match", scalar(@_), "expected exactly 1 parameters" );
914              
915             # Parameter $_[0] (type: Str|RegexpRef)
916 1 50       2 do {
917              
918             package Hydrogen::String::__SANDBOX__;
919             (
920             do {
921              
922             package Hydrogen::String::__SANDBOX__;
923 1 50       7 defined( $_[0] ) and do {
924 1 50       10 ref( \$_[0] ) eq 'SCALAR'
925             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
926             }
927             }
928             or (
929 1 50       4 do {
930              
931             package Hydrogen::String::__SANDBOX__;
932 4     4   15239 use Scalar::Util ();
  4         13  
  4         120  
933 4     4   24 use re ();
  4         8  
  4         1302  
934 0 0 0     0 ref( $_[0] ) && !!re::is_regexp( $_[0] )
      0        
935             or Scalar::Util::blessed( $_[0] )
936             && $_[0]->isa('Regexp');
937             }
938             )
939             );
940             }
941             or Hydrogen::croak(
942             "Type check failed in signature for match: %s should be %s",
943             "\$_[0]", "Str|RegexpRef" );
944              
945 1         5 (@_);
946             };
947 1         26 $_ =~ /$_[0]/;
948             }
949              
950             =head2 C<< match_i( $regexp ) >>
951              
952             Operates on C<< $_ >>, which must be a string scalar.
953              
954             Arguments: B<< Str|RegexpRef >>.
955              
956             Returns true iff the string matches the regexp case-insensitively.
957              
958             =cut
959              
960             sub match_i {
961              
962             package Hydrogen::String::__SANDBOX__;
963 1     1 1 3763 @_ = do {
964 1         3 my ( %tmp, $tmp );
965              
966 1 50       5 @_ == 1
967             or Hydrogen::croak(
968             "Wrong number of parameters in signature for %s: got %d, %s",
969             "match_i", scalar(@_), "expected exactly 1 parameters" );
970              
971             # Parameter $_[0] (type: Str|RegexpRef)
972 1 50       3 do {
973              
974             package Hydrogen::String::__SANDBOX__;
975             (
976             do {
977              
978             package Hydrogen::String::__SANDBOX__;
979 1 50       5 defined( $_[0] ) and do {
980 1 50       10 ref( \$_[0] ) eq 'SCALAR'
981             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
982             }
983             }
984             or (
985 1 50       3 do {
986              
987             package Hydrogen::String::__SANDBOX__;
988 4     4   31 use Scalar::Util ();
  4         7  
  4         92  
989 4     4   21 use re ();
  4         7  
  4         3573  
990 0 0 0     0 ref( $_[0] ) && !!re::is_regexp( $_[0] )
      0        
991             or Scalar::Util::blessed( $_[0] )
992             && $_[0]->isa('Regexp');
993             }
994             )
995             );
996             }
997             or Hydrogen::croak(
998             "Type check failed in signature for match_i: %s should be %s",
999             "\$_[0]", "Str|RegexpRef" );
1000              
1001 1         5 (@_);
1002             };
1003 1         26 $_ =~ /$_[0]/i;
1004             }
1005              
1006             =head2 C<< ne( $str ) >>
1007              
1008             Operates on C<< $_ >>, which must be a string scalar.
1009              
1010             Arguments: B<< Str >>.
1011              
1012             Returns C<< $_ ne $str >>.
1013              
1014             =cut
1015              
1016             sub ne {
1017              
1018             package Hydrogen::String::__SANDBOX__;
1019 0     0 1 0 @_ = do {
1020 0         0 my ( %tmp, $tmp );
1021              
1022 0 0       0 @_ == 1
1023             or Hydrogen::croak(
1024             "Wrong number of parameters in signature for %s: got %d, %s",
1025             "ne", scalar(@_), "expected exactly 1 parameters" );
1026              
1027             # Parameter $_[0] (type: Str)
1028 0 0       0 do {
1029              
1030             package Hydrogen::String::__SANDBOX__;
1031 0 0       0 defined( $_[0] ) and do {
1032 0 0       0 ref( \$_[0] ) eq 'SCALAR'
1033             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
1034             }
1035             }
1036             or Hydrogen::croak(
1037             "Type check failed in signature for ne: %s should be %s",
1038             "\$_[0]", "Str" );
1039              
1040 0         0 (@_);
1041             };
1042 0         0 $_ ne $_[0];
1043             }
1044              
1045             =head2 C<< nei( $str ) >>
1046              
1047             Operates on C<< $_ >>, which must be a string scalar.
1048              
1049             Arguments: B<< Str >>.
1050              
1051             Returns C<< fc($_) ne fc($str) >>. Uses C instead of C in versions of Perl older than 5.16.
1052              
1053             =cut
1054              
1055             sub nei {
1056              
1057             package Hydrogen::String::__SANDBOX__;
1058 0     0 1 0 @_ = do {
1059 0         0 my ( %tmp, $tmp );
1060              
1061 0 0       0 @_ == 1
1062             or Hydrogen::croak(
1063             "Wrong number of parameters in signature for %s: got %d, %s",
1064             "nei", scalar(@_), "expected exactly 1 parameters" );
1065              
1066             # Parameter $_[0] (type: Str)
1067 0 0       0 do {
1068              
1069             package Hydrogen::String::__SANDBOX__;
1070 0 0       0 defined( $_[0] ) and do {
1071 0 0       0 ref( \$_[0] ) eq 'SCALAR'
1072             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
1073             }
1074             }
1075             or Hydrogen::croak(
1076             "Type check failed in signature for nei: %s should be %s",
1077             "\$_[0]", "Str" );
1078              
1079 0         0 (@_);
1080             };
1081 0         0 Hydrogen::fc($_) ne Hydrogen::fc( $_[0] );
1082             }
1083              
1084             =head2 C<< prepend( $head ) >>
1085              
1086             Operates on C<< $_ >>, which must be a string scalar.
1087              
1088             Arguments: B<< Str >>.
1089              
1090             Prepends another string to the start of the current string and updates the original value.
1091              
1092             =cut
1093              
1094             sub prepend {
1095              
1096             package Hydrogen::String::__SANDBOX__;
1097 1     1 1 8547 @_ = do {
1098 1         4 my ( %tmp, $tmp );
1099              
1100 1 50       5 @_ == 1
1101             or Hydrogen::croak(
1102             "Wrong number of parameters in signature for %s: got %d, %s",
1103             "prepend", scalar(@_), "expected exactly 1 parameters" );
1104              
1105             # Parameter $_[0] (type: Str)
1106 1 50       18 do {
1107              
1108             package Hydrogen::String::__SANDBOX__;
1109 1 50       7 defined( $_[0] ) and do {
1110 1 50       12 ref( \$_[0] ) eq 'SCALAR'
1111             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
1112             }
1113             }
1114             or Hydrogen::croak(
1115             "Type check failed in signature for prepend: %s should be %s",
1116             "\$_[0]", "Str" );
1117              
1118 1         5 (@_);
1119             };
1120             (
1121 1         3 $_ = do {
1122 1         3 my $shv_final_unchecked = $_[0] . $_;
1123 1         2 do {
1124 1 50       3 do {
1125              
1126             package Hydrogen::String::__SANDBOX__;
1127 1 50       4 defined($shv_final_unchecked) and do {
1128 1 50       9 ref( \$shv_final_unchecked ) eq 'SCALAR'
1129             or ref( \( my $val = $shv_final_unchecked ) ) eq
1130             'SCALAR';
1131             }
1132             }
1133             or Hydrogen::croak(
1134             "Type check failed for prepend: expected %s, got value %s",
1135             "Str", $shv_final_unchecked
1136             );
1137 1         6 $shv_final_unchecked;
1138             };
1139             }
1140             );
1141             }
1142              
1143             =head2 C<< replace( $regexp, $replacement ) >>
1144              
1145             Operates on C<< $_ >>, which must be a string scalar.
1146              
1147             Arguments: B<< Str|RegexpRef >>, B<< Str|CodeRef >>.
1148              
1149             Replaces the first regexp match within the string with the replacement string.
1150              
1151             =cut
1152              
1153             sub replace {
1154              
1155             package Hydrogen::String::__SANDBOX__;
1156 2     2 1 4361 @_ = do {
1157 2         6 my ( %tmp, $tmp );
1158              
1159 2 50       9 @_ == 2
1160             or Hydrogen::croak(
1161             "Wrong number of parameters in signature for %s: got %d, %s",
1162             "replace", scalar(@_), "expected exactly 2 parameters" );
1163              
1164             # Parameter $_[0] (type: Str|RegexpRef)
1165 2 50       5 do {
1166              
1167             package Hydrogen::String::__SANDBOX__;
1168             (
1169             do {
1170              
1171             package Hydrogen::String::__SANDBOX__;
1172 2 50       46 defined( $_[0] ) and do {
1173 2 100       23 ref( \$_[0] ) eq 'SCALAR'
1174             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
1175             }
1176             }
1177             or (
1178 2 100       4 do {
1179              
1180             package Hydrogen::String::__SANDBOX__;
1181 4     4   37 use Scalar::Util ();
  4         15  
  4         102  
1182 4     4   22 use re ();
  4         8  
  4         2130  
1183 1 50 0     14 ref( $_[0] ) && !!re::is_regexp( $_[0] )
      33        
1184             or Scalar::Util::blessed( $_[0] )
1185             && $_[0]->isa('Regexp');
1186             }
1187             )
1188             );
1189             }
1190             or Hydrogen::croak(
1191             "Type check failed in signature for replace: %s should be %s",
1192             "\$_[0]", "Str|RegexpRef" );
1193              
1194             # Parameter $_[1] (type: Str|CodeRef)
1195 2 50       5 do {
1196              
1197             package Hydrogen::String::__SANDBOX__;
1198             (
1199 2 100       4 do {
1200              
1201             package Hydrogen::String::__SANDBOX__;
1202 2 50       6 defined( $_[1] ) and do {
1203 2 100       18 ref( \$_[1] ) eq 'SCALAR'
1204             or ref( \( my $val = $_[1] ) ) eq 'SCALAR';
1205             }
1206             }
1207             or ( ref( $_[1] ) eq 'CODE' )
1208             );
1209             }
1210             or Hydrogen::croak(
1211             "Type check failed in signature for replace: %s should be %s",
1212             "\$_[1]", "Str|CodeRef" );
1213              
1214 2         8 (@_);
1215             };
1216 2         5 my $shv_tmp = $_;
1217 2 100       7 if ( ( ref( $_[1] ) eq 'CODE' ) ) {
1218 1         3 my $shv_callback = $_[1];
1219 1         9 $shv_tmp =~ s/$_[0]/$shv_callback->()/e;
  1         4  
1220             }
1221 1         24 else { $shv_tmp =~ s/$_[0]/$_[1]/ }
1222             (
1223 2         9 $_ = do {
1224 2         5 my $shv_final_unchecked = $shv_tmp;
1225 2         23 do {
1226 2 50       4 do {
1227              
1228             package Hydrogen::String::__SANDBOX__;
1229 2 50       8 defined($shv_final_unchecked) and do {
1230 2 50       12 ref( \$shv_final_unchecked ) eq 'SCALAR'
1231             or ref( \( my $val = $shv_final_unchecked ) ) eq
1232             'SCALAR';
1233             }
1234             }
1235             or Hydrogen::croak(
1236             "Type check failed for replace: expected %s, got value %s",
1237             "Str", $shv_final_unchecked
1238             );
1239 2         11 $shv_final_unchecked;
1240             };
1241             }
1242             );
1243             }
1244              
1245             =head2 C<< replace_globally( $regexp, $replacement ) >>
1246              
1247             Operates on C<< $_ >>, which must be a string scalar.
1248              
1249             Arguments: B<< Str|RegexpRef >>, B<< Str|CodeRef >>.
1250              
1251             Replaces the all regexp matches within the string with the replacement string.
1252              
1253             =cut
1254              
1255             sub replace_globally {
1256              
1257             package Hydrogen::String::__SANDBOX__;
1258 2     2 1 4522 @_ = do {
1259 2         6 my ( %tmp, $tmp );
1260              
1261 2 50       8 @_ == 2
1262             or Hydrogen::croak(
1263             "Wrong number of parameters in signature for %s: got %d, %s",
1264             "replace_globally", scalar(@_), "expected exactly 2 parameters" );
1265              
1266             # Parameter $_[0] (type: Str|RegexpRef)
1267 2 50       6 do {
1268              
1269             package Hydrogen::String::__SANDBOX__;
1270             (
1271             do {
1272              
1273             package Hydrogen::String::__SANDBOX__;
1274 2 50       8 defined( $_[0] ) and do {
1275 2 100       21 ref( \$_[0] ) eq 'SCALAR'
1276             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
1277             }
1278             }
1279             or (
1280 2 100       4 do {
1281              
1282             package Hydrogen::String::__SANDBOX__;
1283 4     4   35 use Scalar::Util ();
  4         11  
  4         127  
1284 4     4   29 use re ();
  4         9  
  4         9593  
1285 1 50 0     12 ref( $_[0] ) && !!re::is_regexp( $_[0] )
      33        
1286             or Scalar::Util::blessed( $_[0] )
1287             && $_[0]->isa('Regexp');
1288             }
1289             )
1290             );
1291             }
1292             or Hydrogen::croak(
1293             "Type check failed in signature for replace_globally: %s should be %s",
1294             "\$_[0]", "Str|RegexpRef"
1295             );
1296              
1297             # Parameter $_[1] (type: Str|CodeRef)
1298 2 50       4 do {
1299              
1300             package Hydrogen::String::__SANDBOX__;
1301             (
1302 2 100       4 do {
1303              
1304             package Hydrogen::String::__SANDBOX__;
1305 2 50       15 defined( $_[1] ) and do {
1306 2 100       19 ref( \$_[1] ) eq 'SCALAR'
1307             or ref( \( my $val = $_[1] ) ) eq 'SCALAR';
1308             }
1309             }
1310             or ( ref( $_[1] ) eq 'CODE' )
1311             );
1312             }
1313             or Hydrogen::croak(
1314             "Type check failed in signature for replace_globally: %s should be %s",
1315             "\$_[1]", "Str|CodeRef"
1316             );
1317              
1318 2         9 (@_);
1319             };
1320 2         6 my $shv_tmp = $_;
1321 2 100       7 if ( ( ref( $_[1] ) eq 'CODE' ) ) {
1322 1         3 my $shv_callback = $_[1];
1323 1         11 $shv_tmp =~ s/$_[0]/$shv_callback->()/eg;
  2         11  
1324             }
1325 1         21 else { $shv_tmp =~ s/$_[0]/$_[1]/g }
1326             (
1327 2         9 $_ = do {
1328 2         5 my $shv_final_unchecked = $shv_tmp;
1329 2         3 do {
1330 2 50       29 do {
1331              
1332             package Hydrogen::String::__SANDBOX__;
1333 2 50       8 defined($shv_final_unchecked) and do {
1334 2 50       14 ref( \$shv_final_unchecked ) eq 'SCALAR'
1335             or ref( \( my $val = $shv_final_unchecked ) ) eq
1336             'SCALAR';
1337             }
1338             }
1339             or Hydrogen::croak(
1340             "Type check failed for replace_globally: expected %s, got value %s",
1341             "Str", $shv_final_unchecked
1342             );
1343 2         10 $shv_final_unchecked;
1344             };
1345             }
1346             );
1347             }
1348              
1349             =head2 C<< reset() >>
1350              
1351             Operates on C<< $_ >>, which must be a string scalar.
1352              
1353             Resets the original value to its default value, or an empty string if it has no default.
1354              
1355             =cut
1356              
1357             sub reset {
1358              
1359             package Hydrogen::String::__SANDBOX__;
1360 0 0   0 1 0 @_ == 0
1361             or Hydrogen::croak( "Wrong number of parameters for reset; usage: "
1362             . "Hydrogen::Topic::String::reset()" );
1363             (
1364 0         0 $_ = do {
1365 0         0 my $shv_final_unchecked = q{};
1366 0         0 do {
1367 0 0       0 do {
1368              
1369             package Hydrogen::String::__SANDBOX__;
1370 0 0       0 defined($shv_final_unchecked) and do {
1371 0 0       0 ref( \$shv_final_unchecked ) eq 'SCALAR'
1372             or ref( \( my $val = $shv_final_unchecked ) ) eq
1373             'SCALAR';
1374             }
1375             }
1376             or Hydrogen::croak(
1377             "Type check failed for reset: expected %s, got value %s",
1378             "Str", $shv_final_unchecked );
1379 0         0 $shv_final_unchecked;
1380             };
1381             }
1382             );
1383             }
1384              
1385             =head2 C<< set( $value ) >>
1386              
1387             Operates on C<< $_ >>, which must be a string scalar.
1388              
1389             Arguments: B<< Str >>.
1390              
1391             Sets the string to a new value.
1392              
1393             =cut
1394              
1395             sub set {
1396              
1397             package Hydrogen::String::__SANDBOX__;
1398 1     1 1 6379 @_ = do {
1399 1         3 my ( %tmp, $tmp );
1400              
1401 1 50       5 @_ == 1
1402             or Hydrogen::croak(
1403             "Wrong number of parameters in signature for %s: got %d, %s",
1404             "set", scalar(@_), "expected exactly 1 parameters" );
1405              
1406             # Parameter $_[0] (type: Str)
1407 1 50       3 do {
1408              
1409             package Hydrogen::String::__SANDBOX__;
1410 1 50       5 defined( $_[0] ) and do {
1411 1 50       10 ref( \$_[0] ) eq 'SCALAR'
1412             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
1413             }
1414             }
1415             or Hydrogen::croak(
1416             "Type check failed in signature for set: %s should be %s",
1417             "\$_[0]", "Str" );
1418              
1419 1         4 (@_);
1420             };
1421             (
1422 1         3 $_ = do {
1423 1         3 my $shv_final_unchecked = $_[0];
1424 1         2 do {
1425 1 50       2 do {
1426              
1427             package Hydrogen::String::__SANDBOX__;
1428 1 50       7 defined($shv_final_unchecked) and do {
1429 1 50       7 ref( \$shv_final_unchecked ) eq 'SCALAR'
1430             or ref( \( my $val = $shv_final_unchecked ) ) eq
1431             'SCALAR';
1432             }
1433             }
1434             or Hydrogen::croak(
1435             "Type check failed for set: expected %s, got value %s",
1436             "Str", $shv_final_unchecked );
1437 1         5 $shv_final_unchecked;
1438             };
1439             }
1440             );
1441             }
1442              
1443             =head2 C<< starts_with( $head ) >>
1444              
1445             Operates on C<< $_ >>, which must be a string scalar.
1446              
1447             Arguments: B<< Str >>.
1448              
1449             Returns true iff the string starts with C<< $head >>.
1450              
1451             =cut
1452              
1453             sub starts_with {
1454              
1455             package Hydrogen::String::__SANDBOX__;
1456 0     0 1   @_ = do {
1457 0           my ( %tmp, $tmp );
1458              
1459 0 0         @_ == 1
1460             or Hydrogen::croak(
1461             "Wrong number of parameters in signature for %s: got %d, %s",
1462             "starts_with", scalar(@_), "expected exactly 1 parameters" );
1463              
1464             # Parameter $_[0] (type: Str)
1465 0 0         do {
1466              
1467             package Hydrogen::String::__SANDBOX__;
1468 0 0         defined( $_[0] ) and do {
1469 0 0         ref( \$_[0] ) eq 'SCALAR'
1470             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
1471             }
1472             }
1473             or Hydrogen::croak(
1474             "Type check failed in signature for starts_with: %s should be %s",
1475             "\$_[0]", "Str" );
1476              
1477 0           (@_);
1478             };
1479 0           substr( $_, 0, length $_[0] ) eq $_[0];
1480             }
1481              
1482             =head2 C<< starts_with_i( $head ) >>
1483              
1484             Operates on C<< $_ >>, which must be a string scalar.
1485              
1486             Arguments: B<< Str >>.
1487              
1488             Returns true iff the string starts with C<< $head >> case-insensitvely.
1489              
1490             =cut
1491              
1492             sub starts_with_i {
1493              
1494             package Hydrogen::String::__SANDBOX__;
1495 0     0 1   @_ = do {
1496 0           my ( %tmp, $tmp );
1497              
1498 0 0         @_ == 1
1499             or Hydrogen::croak(
1500             "Wrong number of parameters in signature for %s: got %d, %s",
1501             "starts_with_i", scalar(@_), "expected exactly 1 parameters" );
1502              
1503             # Parameter $_[0] (type: Str)
1504 0 0         do {
1505              
1506             package Hydrogen::String::__SANDBOX__;
1507 0 0         defined( $_[0] ) and do {
1508 0 0         ref( \$_[0] ) eq 'SCALAR'
1509             or ref( \( my $val = $_[0] ) ) eq 'SCALAR';
1510             }
1511             }
1512             or Hydrogen::croak(
1513             "Type check failed in signature for starts_with_i: %s should be %s",
1514             "\$_[0]", "Str"
1515             );
1516              
1517 0           (@_);
1518             };
1519 0           Hydrogen::fc( substr( $_, 0, length $_[0] ) ) eq Hydrogen::fc( $_[0] );
1520             }
1521              
1522             =head2 C<< substr( $start, $length?, $replacement? ) >>
1523              
1524             Operates on C<< $_ >>, which must be a string scalar.
1525              
1526             Arguments: B<< Int >>, B<< Optional[Int] >>, B<< Optional[Str] >>.
1527              
1528             Like C from L, but is not an lvalue.
1529              
1530             =cut
1531              
1532             {
1533             my $__signature;
1534              
1535             sub substr {
1536              
1537             package Hydrogen::String::__SANDBOX__;
1538             $__signature ||= sub {
1539 0     0     my ( %tmp, $tmp );
1540              
1541 0 0 0       @_ >= 1 && @_ <= 3
1542             or Hydrogen::croak(
1543             "Wrong number of parameters in signature for %s: got %d, %s",
1544             "substr", scalar(@_), "expected exactly 1 parameters" );
1545              
1546             # Parameter $_[0] (type: Int)
1547             (
1548 0 0         do {
1549 0           my $tmp = $_[0];
1550 0 0 0       defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/;
1551             }
1552             )
1553             or Hydrogen::croak(
1554             "Type check failed in signature for substr: %s should be %s",
1555             "\$_[0]", "Int" );
1556              
1557             # Parameter $_[1] (type: Optional[Int])
1558 0 0         $#_ >= 1
1559             or return (@_);
1560             (
1561 0 0         do {
1562 0           my $tmp = $_[1];
1563 0 0 0       defined($tmp) and !ref($tmp) and $tmp =~ /\A-?[0-9]+\z/;
1564             }
1565             )
1566             or Hydrogen::croak(
1567             "Type check failed in signature for substr: %s should be %s",
1568             "\$_[1]", "Optional[Int]" );
1569              
1570             # Parameter $_[2] (type: Optional[Str])
1571 0 0         $#_ >= 2
1572             or return (@_);
1573 0 0         do {
1574              
1575             package Hydrogen::String::__SANDBOX__;
1576 0 0         defined( $_[2] ) and do {
1577 0 0         ref( \$_[2] ) eq 'SCALAR'
1578             or ref( \( my $val = $_[2] ) ) eq 'SCALAR';
1579             }
1580             }
1581             or Hydrogen::croak(
1582             "Type check failed in signature for substr: %s should be %s",
1583             "\$_[2]", "Optional[Str]" );
1584              
1585 0           (@_);
1586 0   0 0 1   };
1587 0           @_ = &$__signature;
1588 0 0         if ( ( 0 + @_ ) == 1 ) { substr( $_, $_[0] ) }
  0 0          
    0          
1589 0           elsif ( ( 0 + @_ ) == 2 ) { substr( $_, $_[0], $_[1] ) }
1590             elsif ( ( 0 + @_ ) == 3 ) {
1591 0           my $shv_tmp = $_;
1592 0           my $shv_return = substr( $shv_tmp, $_[0], $_[1], $_[2] );
1593             (
1594 0           $_ = do {
1595 0           my $shv_final_unchecked = $shv_tmp;
1596 0           do {
1597 0 0         do {
1598              
1599             package Hydrogen::String::__SANDBOX__;
1600 0 0         defined($shv_final_unchecked) and do {
1601 0 0         ref( \$shv_final_unchecked ) eq 'SCALAR'
1602             or ref( \( my $val = $shv_final_unchecked ) )
1603             eq 'SCALAR';
1604             }
1605             }
1606             or Hydrogen::croak(
1607             "Type check failed for substr: expected %s, got value %s",
1608             "Str", $shv_final_unchecked
1609             );
1610 0           $shv_final_unchecked;
1611             };
1612             }
1613             );
1614 0           $shv_return;
1615             }
1616             }
1617             }
1618              
1619             =head2 C<< trim() >>
1620              
1621             Operates on C<< $_ >>, which must be a string scalar.
1622              
1623             Like C from L, but in-place.
1624              
1625             =cut
1626              
1627             sub trim {
1628              
1629             package Hydrogen::String::__SANDBOX__;
1630 0 0   0 1   @_ == 0
1631             or Hydrogen::croak( "Wrong number of parameters for trim; usage: "
1632             . "Hydrogen::Topic::String::trim()" );
1633 0           1;
1634 0           s/\A\s+//, s/\s+\z// for $_;
1635             }
1636              
1637             =head2 C<< uc() >>
1638              
1639             Operates on C<< $_ >>, which must be a string scalar.
1640              
1641             Returns C<< uc($_) >>.
1642              
1643             =cut
1644              
1645             sub uc {
1646              
1647             package Hydrogen::String::__SANDBOX__;
1648 0 0   0 1   @_ == 0
1649             or Hydrogen::croak( "Wrong number of parameters for uc; usage: "
1650             . "Hydrogen::Topic::String::uc()" );
1651 0           uc($_);
1652             }
1653              
1654             1;
1655              
1656             =head1 EXPORT
1657              
1658             No functions are exported by this module by default. To import them all (this is usually a bad idea), use:
1659              
1660             use Hydrogen::Topic::String -all;
1661              
1662             To import a particular function, use:
1663              
1664             use Hydrogen::Topic::String 'chop';
1665              
1666             To rename functions:
1667              
1668             use Hydrogen::Topic::String 'chop' => { -as => 'myfunc' };
1669              
1670             On Perl 5.37.2+ (or if L is installed) you can import lexically:
1671              
1672             use Hydrogen::Topic::String -lexical, 'chop';
1673              
1674             See L for more hints on importing.
1675              
1676             =head1 BUGS
1677              
1678             Please report any bugs to
1679             L.
1680              
1681             =head1 SEE ALSO
1682              
1683             L,
1684             L,
1685             L,
1686             L,
1687             L.
1688              
1689             =head1 AUTHOR
1690              
1691             Toby Inkster Etobyink@cpan.orgE.
1692              
1693             =head1 COPYRIGHT AND LICENCE
1694              
1695             This software is copyright (c) 2022-2025 by Toby Inkster.
1696              
1697             This is free software; you can redistribute it and/or modify it under
1698             the same terms as the Perl 5 programming language system itself.
1699              
1700             =head1 DISCLAIMER OF WARRANTIES
1701              
1702             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
1703             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
1704             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1705