File Coverage

blib/lib/Hydrogen/Topic/String.pm
Criterion Covered Total %
statement 160 374 42.7
branch 72 340 21.1
condition 2 35 5.7
subroutine 24 53 45.2
pod 38 38 100.0
total 296 840 35.2


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