1Data::Perl::Role::StrinUgs(e3r)Contributed Perl DocumentDaattiao:n:Perl::Role::String(3)
2
3
4

NAME

6       Data::Perl::Role::String - Wrapping class for Perl scalar strings.
7

VERSION

9       version 0.002011
10

SYNOPSIS

12         use Data::Perl qw/string/;
13
14         my $string = string("foo\n");
15
16         $string->chomp; # returns 1, $string == "foo"
17

DESCRIPTION

19       This class provides a wrapper and methods for interacting with scalar
20       strings.
21

PROVIDED METHODS

23       ·   new($value)
24
25           Constructs a new Data::Perl::String object, optionally initialized
26           to $value if passed in, and returns it.
27
28       ·   inc
29
30           Increments the value stored in this slot using the magical string
31           autoincrement operator. Note that Perl doesn't provide analogous
32           behavior in "--", so "dec" is not available. This method returns
33           the new value.
34
35           This method does not accept any arguments.
36
37       ·   append($string)
38
39           Appends to the string, like ".=", and returns the new value.
40
41           This method requires a single argument.
42
43       ·   prepend($string)
44
45           Prepends to the string and returns the new value.
46
47           This method requires a single argument.
48
49       ·   replace($pattern, $replacement)
50
51           Performs a regexp substitution ("s" in perlop). There is no way to
52           provide the "g" flag, but code references will be accepted for the
53           replacement, causing the regex to be modified with a single "e".
54           "/smxi" can be applied using the "qr" operator. This method returns
55           the new value.
56
57           This method requires two arguments.
58
59       ·   match($pattern)
60
61           Runs the regex against the string and returns the matching
62           value(s).
63
64           This method requires a single argument.
65
66       ·   chop
67
68           Just like "chop" in perlfunc. This method returns the chopped
69           character.
70
71           This method does not accept any arguments.
72
73       ·   chomp
74
75           Just like "chomp" in perlfunc. This method returns the number of
76           characters removed.
77
78           This method does not accept any arguments.
79
80       ·   clear
81
82           Sets the string to the empty string (not the value passed to
83           "default").
84
85           This method does not have a defined return value.
86
87           This method does not accept any arguments.
88
89       ·   length
90
91           Just like "length" in perlfunc, returns the length of the string.
92
93       ·   substr
94
95           This acts just like "substr" in perlfunc. When called as a writer,
96           it returns the substring that was replaced, just like the Perl
97           builtin.
98
99           This method requires at least one argument, and accepts no more
100           than three.
101

SEE ALSO

103       ·   Data::Perl
104
105       ·   MooX::HandlesVia
106

AUTHOR

108       Matthew Phillips <mattp@cpan.org>
109
111       This software is copyright (c) 2020 by Matthew Phillips
112       <mattp@cpan.org>.
113
114       This is free software; you can redistribute it and/or modify it under
115       the same terms as the Perl 5 programming language system itself.
116
117
118
119perl v5.32.0                      2020-07-28       Data::Perl::Role::String(3)
Impressum