.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MouseX::NativeTraits::Str 3pm" .TH MouseX::NativeTraits::Str 3pm "2020-12-28" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MouseX::NativeTraits::Str \- Helper trait for Str attributes .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& package MyHomePage; \& use Mouse; \& \& has \*(Aqtext\*(Aq => ( \& traits => [\*(AqString\*(Aq], \& is => \*(Aqrw\*(Aq, \& isa => \*(AqStr\*(Aq, \& default => q{}, \& handles => { \& add_text => \*(Aqappend\*(Aq, \& replace_text => \*(Aqreplace\*(Aq, \& }, \& ); \& \& my $page = MyHomePage\->new(); \& $page\->add_text("foo"); # same as $page\->text($page\->text . "foo"); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides a simple string attribute, to which mutating string operations can be applied more easily (no need to make an lvalue attribute metaclass or use temporary variables). Additional methods are provided for completion. .SH "PROVIDED METHODS" .IX Header "PROVIDED METHODS" These methods are implemented in MouseX::NativeTraits::MethodProvider::Str. It is important to note that all those methods do in place modification of the value stored in the attribute. .IP "\fBinc\fR" 4 .IX Item "inc" Increments the value stored in this slot using the magical string autoincrement operator. Note that Perl doesn't provide analogous behavior in \f(CW\*(C`\-\-\*(C'\fR, so \&\f(CW\*(C`dec\*(C'\fR is not available. .IP "\fBappend($string)\fR" 4 .IX Item "append($string)" Append a string, like \f(CW\*(C`.=\*(C'\fR. .IP "\fBprepend($string)\fR" 4 .IX Item "prepend($string)" Prepend a string. .IP "\fBreplace($pattern, \f(CB$replacement\fB)\fR" 4 .IX Item "replace($pattern, $replacement)" Performs a regexp substitution (\*(L"s\*(R" in perlop). A code references will be accepted for the replacement, causing the regexp to be modified with a single \f(CW\*(C`e\*(C'\fR. \f(CW\*(C`/smxi\*(C'\fR can be applied using the \&\f(CW\*(C`qr\*(C'\fR operator. .IP "\fBreplace($pattern, \f(CB$replacement\fB)\fR" 4 .IX Item "replace($pattern, $replacement)" Performs a regexp substitution (\*(L"s\*(R" in perlop) with the \f(CW\*(C`g\*(C'\fR flag. A code references will be accepted for the replacement, causing the regexp to be modified with a single \f(CW\*(C`e\*(C'\fR. \f(CW\*(C`/smxi\*(C'\fR can be applied using the \&\f(CW\*(C`qr\*(C'\fR operator. .IP "\fBmatch($pattern)\fR" 4 .IX Item "match($pattern)" Like \f(CW\*(C`replace\*(C'\fR but without the replacement. Provided mostly for completeness. .IP "\fBchop\fR" 4 .IX Item "chop" \&\*(L"chop\*(R" in perlfunc .IP "\fBchomp\fR" 4 .IX Item "chomp" \&\*(L"chomp\*(R" in perlfunc .IP "\fBclear\fR" 4 .IX Item "clear" Sets the string to the empty string (not the value passed to \f(CW\*(C`default\*(C'\fR). .IP "\fBlength\fR" 4 .IX Item "length" \&\*(L"length\*(R" in perlfunc .IP "\fBsubstr\fR" 4 .IX Item "substr" \&\*(L"substr\*(R" in perlfunc. We go to some lengths to match the different functionality based on \f(CW\*(C`substr\*(C'\fR's arity. .SH "METHODS" .IX Header "METHODS" .IP "\fBmeta\fR" 4 .IX Item "meta" .PD 0 .IP "\fBmethod_provider_class\fR" 4 .IX Item "method_provider_class" .IP "\fBhelper_type\fR" 4 .IX Item "helper_type" .PD .SH "SEE ALSO" .IX Header "SEE ALSO" MouseX::NativeTraits