| 1 | package Venus::Replace; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use 5.018; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | ▶ | use Venus::Class 'attr', 'base', 'with'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 3 | base 'Venus::Kind::Utility'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 3 | with 'Venus::Role::Explainable'; | |||||||||||||||||||
| 13 | 3 | with 'Venus::Role::Stashable'; | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | use overload ( | ||||||||||||||||||||
| 16 | '""' => 'explain', | ||||||||||||||||||||
| 17 | 1 | ▶ | 'eq' => sub{"$_[0]" eq "$_[1]"}, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 18 | 1 | ▶ | 'ne' => sub{"$_[0]" ne "$_[1]"}, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 19 | 1 | ▶ | 'qr' => sub{qr{@{[quotemeta("$_[0]")]}}}, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 20 | 3 | '~~' => 'explain', | |||||||||||||||||||
| 21 | fallback => 1, | ||||||||||||||||||||
| 22 | 3 | ▶ | ); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | # ATTRIBUTES | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 3 | attr 'flags'; | |||||||||||||||||||
| 27 | 3 | attr 'regexp'; | |||||||||||||||||||
| 28 | 3 | attr 'string'; | |||||||||||||||||||
| 29 | 3 | attr 'substr'; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | # BUILDERS | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | sub build_self { | ||||||||||||||||||||
| 34 | 25 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||
|
Subroutine
build_self: called CC=5 SCAR=17.2
Pod
undocumented
| |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 25 | ▶ | $self->flags('') if !$self->flags; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 25 | ▶ | $self->regexp(qr//) if !defined $self->regexp; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | 25 | ▶ | $self->string('') if !defined $self->string; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | 25 | ▶ | $self->substr('') if !defined $self->substr; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 25 | return $self; | |||||||||||||||||||
| 42 | } | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | # METHODS | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | sub captures { | ||||||||||||||||||||
| 47 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
captures: called CC=6 SCAR=18.6
Pod
documented
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 1 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition33%1/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table33%1/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 1 | my $string = $self->initial; | |||||||||||||||||||
| 52 | 1 | my $last_match_start = $self->last_match_start; | |||||||||||||||||||
| 53 | 1 | my $last_match_end = $self->last_match_end; | |||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 1 | my $captures = []; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 1 | ▶ | for (my $i = 1; $i < @$last_match_end; $i++) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | 1 | ▶ | my $start = $last_match_start->[$i] || 0; | ||||||||||||||||||
|
Condition50%1/2
$last_match_start->[$i] || 0
MC/DC0%0/1
$last_match_start->[$i] || 0
$last_match_start->[$i]
Truth table50%1/2
A
A= $last_match_start->[$i]
| |||||||||||||||||||||
| 59 | 1 | ▶ | my $end = $last_match_end->[$i] || 0; | ||||||||||||||||||
|
Condition50%1/2
$last_match_end->[$i] || 0
MC/DC0%0/1
$last_match_end->[$i] || 0
$last_match_end->[$i]
Truth table50%1/2
A
A= $last_match_end->[$i]
| |||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 1 | push @$captures, substr $string, $start, $end - $start; | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | 1 | ▶ | return wantarray ? (@$captures) : $captures; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | sub count { | ||||||||||||||||||||
| 68 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
count: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 1 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition33%1/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table33%1/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 1 | return $evaluation->[2]; | |||||||||||||||||||
| 73 | } | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | sub evaluate { | ||||||||||||||||||||
| 76 | 24 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
evaluate: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 24 | my $captures = 0; | |||||||||||||||||||
| 79 | 24 | my $flags = $self->flags; | |||||||||||||||||||
| 80 | 24 | my @matches = (); | |||||||||||||||||||
| 81 | 24 | my $regexp = $self->regexp; | |||||||||||||||||||
| 82 | 24 | my $string = $self->string; | |||||||||||||||||||
| 83 | 24 | my $substr = $self->substr; | |||||||||||||||||||
| 84 | 24 | my $initial = "$string"; | |||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 24 | local $@; | |||||||||||||||||||
| 87 | 24 | ▶ | eval join ';', ( | ||||||||||||||||||
|
Condition50%1/2
$flags // ""
MC/DC0%0/1
$flags // ""
$flags
Truth table50%1/2
A
A= $flags
| |||||||||||||||||||||
| 88 | '$captures = (' . '$string =~ s/$regexp/$substr/' . ($flags // '') . ')', | ||||||||||||||||||||
| 89 | '@matches = ([@-], [@+], {%-})', | ||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | 24 | my $error = $@; | |||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | 24 | ▶ | if ($error) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 95 | 1 | $self->error({throw => 'error_on_evaluate', error => $error}); | |||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 23 | return $self->stash(evaluation => [ | |||||||||||||||||||
| 99 | $regexp, | ||||||||||||||||||||
| 100 | $string, | ||||||||||||||||||||
| 101 | $captures, | ||||||||||||||||||||
| 102 | @matches, | ||||||||||||||||||||
| 103 | $initial, | ||||||||||||||||||||
| 104 | ]); | ||||||||||||||||||||
| 105 | } | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | sub explain { | ||||||||||||||||||||
| 108 | 17 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
explain: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 17 | return $self->get; | |||||||||||||||||||
| 111 | } | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | sub get { | ||||||||||||||||||||
| 114 | 18 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
get: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 18 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition66%2/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table66%2/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 18 | return $evaluation->[1]; | |||||||||||||||||||
| 119 | } | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | sub initial { | ||||||||||||||||||||
| 122 | 5 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
initial: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | 5 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition66%2/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table66%2/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | 5 | return $evaluation->[6]; | |||||||||||||||||||
| 127 | } | ||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | sub last_match_end { | ||||||||||||||||||||
| 130 | 5 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
last_match_end: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 5 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition66%2/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table66%2/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | 5 | return $evaluation->[4]; | |||||||||||||||||||
| 135 | } | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | sub last_match_start { | ||||||||||||||||||||
| 138 | 5 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
last_match_start: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | 5 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition66%2/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table66%2/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | 5 | return $evaluation->[3]; | |||||||||||||||||||
| 143 | } | ||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | sub matched { | ||||||||||||||||||||
| 146 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
matched: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | 1 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition33%1/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table33%1/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 149 | |||||||||||||||||||||
| 150 | 1 | my $string = $self->initial; | |||||||||||||||||||
| 151 | 1 | my $last_match_start = $self->last_match_start; | |||||||||||||||||||
| 152 | 1 | my $last_match_end = $self->last_match_end; | |||||||||||||||||||
| 153 | |||||||||||||||||||||
| 154 | 1 | ▶ | my $start = $last_match_start->[0] || 0; | ||||||||||||||||||
|
Condition50%1/2
$last_match_start->[0] || 0
MC/DC0%0/1
$last_match_start->[0] || 0
$last_match_start->[0]
Truth table50%1/2
A
A= $last_match_start->[0]
| |||||||||||||||||||||
| 155 | 1 | ▶ | my $end = $last_match_end->[0] || 0; | ||||||||||||||||||
|
Condition50%1/2
$last_match_end->[0] || 0
MC/DC0%0/1
$last_match_end->[0] || 0
$last_match_end->[0]
Truth table50%1/2
A
A= $last_match_end->[0]
| |||||||||||||||||||||
| 156 | |||||||||||||||||||||
| 157 | 1 | return substr $string, $start, $end - $start; | |||||||||||||||||||
| 158 | } | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | sub named_captures { | ||||||||||||||||||||
| 161 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
named_captures: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||
| 162 | |||||||||||||||||||||
| 163 | 2 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition33%1/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table33%1/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 164 | |||||||||||||||||||||
| 165 | 2 | return $evaluation->[5]; | |||||||||||||||||||
| 166 | } | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | sub prematched { | ||||||||||||||||||||
| 169 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
prematched: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||
| 170 | |||||||||||||||||||||
| 171 | 1 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition33%1/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table33%1/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 172 | |||||||||||||||||||||
| 173 | 1 | my $string = $self->initial; | |||||||||||||||||||
| 174 | 1 | my $last_match_start = $self->last_match_start; | |||||||||||||||||||
| 175 | 1 | my $last_match_end = $self->last_match_end; | |||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | 1 | ▶ | my $start = $last_match_start->[0] || 0; | ||||||||||||||||||
|
Condition50%1/2
$last_match_start->[0] || 0
MC/DC0%0/1
$last_match_start->[0] || 0
$last_match_start->[0]
Truth table50%1/2
A
A= $last_match_start->[0]
| |||||||||||||||||||||
| 178 | 1 | ▶ | my $end = $last_match_end->[0] || 0; | ||||||||||||||||||
|
Condition50%1/2
$last_match_end->[0] || 0
MC/DC0%0/1
$last_match_end->[0] || 0
$last_match_end->[0]
Truth table50%1/2
A
A= $last_match_end->[0]
| |||||||||||||||||||||
| 179 | |||||||||||||||||||||
| 180 | 1 | return substr $string, 0, $start; | |||||||||||||||||||
| 181 | } | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | sub postmatched { | ||||||||||||||||||||
| 184 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
postmatched: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||
| 185 | |||||||||||||||||||||
| 186 | 1 | ▶ | my $evaluation = $self->stash('evaluation') || $self->evaluate; | ||||||||||||||||||
|
Condition33%1/3
$self->stash('evaluation') || $self->evaluate
MC/DC0%0/2
$self->stash('evaluation') || $self->evaluate
$self->stash('evaluation')
$self->evaluate
Truth table33%1/3
A || B
A= $self->stash('evaluation')B= $self->evaluate
| |||||||||||||||||||||
| 187 | |||||||||||||||||||||
| 188 | 1 | my $string = $self->initial; | |||||||||||||||||||
| 189 | 1 | my $last_match_start = $self->last_match_start; | |||||||||||||||||||
| 190 | 1 | my $last_match_end = $self->last_match_end; | |||||||||||||||||||
| 191 | |||||||||||||||||||||
| 192 | 1 | ▶ | my $start = $last_match_start->[0] || 0; | ||||||||||||||||||
|
Condition50%1/2
$last_match_start->[0] || 0
MC/DC0%0/1
$last_match_start->[0] || 0
$last_match_start->[0]
Truth table50%1/2
A
A= $last_match_start->[0]
| |||||||||||||||||||||
| 193 | 1 | ▶ | my $end = $last_match_end->[0] || 0; | ||||||||||||||||||
|
Condition50%1/2
$last_match_end->[0] || 0
MC/DC0%0/1
$last_match_end->[0] || 0
$last_match_end->[0]
Truth table50%1/2
A
A= $last_match_end->[0]
| |||||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | 1 | return substr $string, $end; | |||||||||||||||||||
| 196 | } | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | sub set { | ||||||||||||||||||||
| 199 | 1 | ▶ | my ($self, $string) = @_; | ||||||||||||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | 1 | $self->string($string); | |||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | 1 | my $evaluation = $self->evaluate; | |||||||||||||||||||
| 204 | |||||||||||||||||||||
| 205 | 1 | return $evaluation->[1]; | |||||||||||||||||||
| 206 | } | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | # ERRORS | ||||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | sub error_on_evaluate { | ||||||||||||||||||||
| 211 | 2 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||
|
Subroutine
error_on_evaluate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 212 | |||||||||||||||||||||
| 213 | my $result = { | ||||||||||||||||||||
| 214 | name => 'on.evaluate', | ||||||||||||||||||||
| 215 | raise => true, | ||||||||||||||||||||
| 216 | message => $data->{error}, | ||||||||||||||||||||
| 217 | 2 | }; | |||||||||||||||||||
| 218 | |||||||||||||||||||||
| 219 | 2 | return $result; | |||||||||||||||||||
| 220 | } | ||||||||||||||||||||
| 221 | |||||||||||||||||||||
| 222 | 3 | 1; | |||||||||||||||||||
| 223 | |||||||||||||||||||||
| 224 | |||||||||||||||||||||
| 225 | |||||||||||||||||||||
| 226 | =head1 NAME | ||||||||||||||||||||
| 227 | |||||||||||||||||||||
| 228 | Venus::Replace - Replace Class | ||||||||||||||||||||
| 229 | |||||||||||||||||||||
| 230 | =cut | ||||||||||||||||||||
| 231 | |||||||||||||||||||||
| 232 | =head1 ABSTRACT | ||||||||||||||||||||
| 233 | |||||||||||||||||||||
| 234 | Replace Class for Perl 5 | ||||||||||||||||||||
| 235 | |||||||||||||||||||||
| 236 | =cut | ||||||||||||||||||||
| 237 | |||||||||||||||||||||
| 238 | =head1 SYNOPSIS | ||||||||||||||||||||
| 239 | |||||||||||||||||||||
| 240 | package main; | ||||||||||||||||||||
| 241 | |||||||||||||||||||||
| 242 | use Venus::Replace; | ||||||||||||||||||||
| 243 | |||||||||||||||||||||
| 244 | my $replace = Venus::Replace->new( | ||||||||||||||||||||
| 245 | string => 'hello world', | ||||||||||||||||||||
| 246 | regexp => '(world)', | ||||||||||||||||||||
| 247 | substr => 'universe', | ||||||||||||||||||||
| 248 | ); | ||||||||||||||||||||
| 249 | |||||||||||||||||||||
| 250 | # $replace->captures; | ||||||||||||||||||||
| 251 | |||||||||||||||||||||
| 252 | =cut | ||||||||||||||||||||
| 253 | |||||||||||||||||||||
| 254 | =head1 DESCRIPTION | ||||||||||||||||||||
| 255 | |||||||||||||||||||||
| 256 | This package provides methods for manipulating regexp replacement data. | ||||||||||||||||||||
| 257 | |||||||||||||||||||||
| 258 | =cut | ||||||||||||||||||||
| 259 | |||||||||||||||||||||
| 260 | =head1 ATTRIBUTES | ||||||||||||||||||||
| 261 | |||||||||||||||||||||
| 262 | This package has the following attributes: | ||||||||||||||||||||
| 263 | |||||||||||||||||||||
| 264 | =cut | ||||||||||||||||||||
| 265 | |||||||||||||||||||||
| 266 | =head2 flags | ||||||||||||||||||||
| 267 | |||||||||||||||||||||
| 268 | flags(Str) | ||||||||||||||||||||
| 269 | |||||||||||||||||||||
| 270 | This attribute is read-write, accepts C<(Str)> values, is optional, and defaults to C<''>. | ||||||||||||||||||||
| 271 | |||||||||||||||||||||
| 272 | =cut | ||||||||||||||||||||
| 273 | |||||||||||||||||||||
| 274 | =head2 regexp | ||||||||||||||||||||
| 275 | |||||||||||||||||||||
| 276 | regexp(Regexp) | ||||||||||||||||||||
| 277 | |||||||||||||||||||||
| 278 | This attribute is read-write, accepts C<(Regexp)> values, is optional, and defaults to C<qr//>. | ||||||||||||||||||||
| 279 | |||||||||||||||||||||
| 280 | =cut | ||||||||||||||||||||
| 281 | |||||||||||||||||||||
| 282 | =head2 string | ||||||||||||||||||||
| 283 | |||||||||||||||||||||
| 284 | string(Str) | ||||||||||||||||||||
| 285 | |||||||||||||||||||||
| 286 | This attribute is read-write, accepts C<(Str)> values, is optional, and defaults to C<''>. | ||||||||||||||||||||
| 287 | |||||||||||||||||||||
| 288 | =cut | ||||||||||||||||||||
| 289 | |||||||||||||||||||||
| 290 | =head2 substr | ||||||||||||||||||||
| 291 | |||||||||||||||||||||
| 292 | substr(Str) | ||||||||||||||||||||
| 293 | |||||||||||||||||||||
| 294 | This attribute is read-write, accepts C<(Str)> values, is optional, and defaults to C<''>. | ||||||||||||||||||||
| 295 | |||||||||||||||||||||
| 296 | =cut | ||||||||||||||||||||
| 297 | |||||||||||||||||||||
| 298 | =head1 INHERITS | ||||||||||||||||||||
| 299 | |||||||||||||||||||||
| 300 | This package inherits behaviors from: | ||||||||||||||||||||
| 301 | |||||||||||||||||||||
| 302 | L<Venus::Kind::Utility> | ||||||||||||||||||||
| 303 | |||||||||||||||||||||
| 304 | =cut | ||||||||||||||||||||
| 305 | |||||||||||||||||||||
| 306 | =head1 INTEGRATES | ||||||||||||||||||||
| 307 | |||||||||||||||||||||
| 308 | This package integrates behaviors from: | ||||||||||||||||||||
| 309 | |||||||||||||||||||||
| 310 | L<Venus::Role::Explainable> | ||||||||||||||||||||
| 311 | |||||||||||||||||||||
| 312 | L<Venus::Role::Stashable> | ||||||||||||||||||||
| 313 | |||||||||||||||||||||
| 314 | =cut | ||||||||||||||||||||
| 315 | |||||||||||||||||||||
| 316 | =head1 METHODS | ||||||||||||||||||||
| 317 | |||||||||||||||||||||
| 318 | This package provides the following methods: | ||||||||||||||||||||
| 319 | |||||||||||||||||||||
| 320 | =cut | ||||||||||||||||||||
| 321 | |||||||||||||||||||||
| 322 | =head2 captures | ||||||||||||||||||||
| 323 | |||||||||||||||||||||
| 324 | captures() (arrayref) | ||||||||||||||||||||
| 325 | |||||||||||||||||||||
| 326 | The captures method returns the capture groups from the result object which | ||||||||||||||||||||
| 327 | contains information about the results of the regular expression operation. | ||||||||||||||||||||
| 328 | This method can return a list of values in list-context. | ||||||||||||||||||||
| 329 | |||||||||||||||||||||
| 330 | I<Since C<0.01>> | ||||||||||||||||||||
| 331 | |||||||||||||||||||||
| 332 | =over 4 | ||||||||||||||||||||
| 333 | |||||||||||||||||||||
| 334 | =item captures example 1 | ||||||||||||||||||||
| 335 | |||||||||||||||||||||
| 336 | # given: synopsis; | ||||||||||||||||||||
| 337 | |||||||||||||||||||||
| 338 | my $captures = $replace->captures; | ||||||||||||||||||||
| 339 | |||||||||||||||||||||
| 340 | # ["world"] | ||||||||||||||||||||
| 341 | |||||||||||||||||||||
| 342 | =back | ||||||||||||||||||||
| 343 | |||||||||||||||||||||
| 344 | =cut | ||||||||||||||||||||
| 345 | |||||||||||||||||||||
| 346 | =head2 count | ||||||||||||||||||||
| 347 | |||||||||||||||||||||
| 348 | count() (number) | ||||||||||||||||||||
| 349 | |||||||||||||||||||||
| 350 | The count method returns the number of match occurrences from the result object | ||||||||||||||||||||
| 351 | which contains information about the results of the regular expression | ||||||||||||||||||||
| 352 | operation. | ||||||||||||||||||||
| 353 | |||||||||||||||||||||
| 354 | I<Since C<0.01>> | ||||||||||||||||||||
| 355 | |||||||||||||||||||||
| 356 | =over 4 | ||||||||||||||||||||
| 357 | |||||||||||||||||||||
| 358 | =item count example 1 | ||||||||||||||||||||
| 359 | |||||||||||||||||||||
| 360 | # given: synopsis; | ||||||||||||||||||||
| 361 | |||||||||||||||||||||
| 362 | my $count = $replace->count; | ||||||||||||||||||||
| 363 | |||||||||||||||||||||
| 364 | # 1 | ||||||||||||||||||||
| 365 | |||||||||||||||||||||
| 366 | =back | ||||||||||||||||||||
| 367 | |||||||||||||||||||||
| 368 | =cut | ||||||||||||||||||||
| 369 | |||||||||||||||||||||
| 370 | =head2 evaluate | ||||||||||||||||||||
| 371 | |||||||||||||||||||||
| 372 | evaluate() (arrayref) | ||||||||||||||||||||
| 373 | |||||||||||||||||||||
| 374 | The evaluate method performs the regular expression operation and returns an | ||||||||||||||||||||
| 375 | arrayref representation of the results. | ||||||||||||||||||||
| 376 | |||||||||||||||||||||
| 377 | I<Since C<0.01>> | ||||||||||||||||||||
| 378 | |||||||||||||||||||||
| 379 | =over 4 | ||||||||||||||||||||
| 380 | |||||||||||||||||||||
| 381 | =item evaluate example 1 | ||||||||||||||||||||
| 382 | |||||||||||||||||||||
| 383 | # given: synopsis; | ||||||||||||||||||||
| 384 | |||||||||||||||||||||
| 385 | my $evaluate = $replace->evaluate; | ||||||||||||||||||||
| 386 | |||||||||||||||||||||
| 387 | # [ | ||||||||||||||||||||
| 388 | # "(world)", | ||||||||||||||||||||
| 389 | # "hello universe", | ||||||||||||||||||||
| 390 | # 1, | ||||||||||||||||||||
| 391 | # [6, 6], | ||||||||||||||||||||
| 392 | # [11, 11], | ||||||||||||||||||||
| 393 | # {}, | ||||||||||||||||||||
| 394 | # "hello world", | ||||||||||||||||||||
| 395 | # ] | ||||||||||||||||||||
| 396 | |||||||||||||||||||||
| 397 | =back | ||||||||||||||||||||
| 398 | |||||||||||||||||||||
| 399 | =over 4 | ||||||||||||||||||||
| 400 | |||||||||||||||||||||
| 401 | =item evaluate example 2 | ||||||||||||||||||||
| 402 | |||||||||||||||||||||
| 403 | package main; | ||||||||||||||||||||
| 404 | |||||||||||||||||||||
| 405 | use Venus::Replace; | ||||||||||||||||||||
| 406 | |||||||||||||||||||||
| 407 | my $replace = Venus::Replace->new( | ||||||||||||||||||||
| 408 | string => 'hello world', | ||||||||||||||||||||
| 409 | regexp => 'world)(', | ||||||||||||||||||||
| 410 | substr => 'universe', | ||||||||||||||||||||
| 411 | ); | ||||||||||||||||||||
| 412 | |||||||||||||||||||||
| 413 | my $evaluate = $replace->evaluate; | ||||||||||||||||||||
| 414 | |||||||||||||||||||||
| 415 | # Exception! (isa Venus::Replace::Error) (see error_on_evaluate) | ||||||||||||||||||||
| 416 | |||||||||||||||||||||
| 417 | =back | ||||||||||||||||||||
| 418 | |||||||||||||||||||||
| 419 | =cut | ||||||||||||||||||||
| 420 | |||||||||||||||||||||
| 421 | =head2 explain | ||||||||||||||||||||
| 422 | |||||||||||||||||||||
| 423 | explain() (string) | ||||||||||||||||||||
| 424 | |||||||||||||||||||||
| 425 | The explain method returns the subject of the regular expression operation and | ||||||||||||||||||||
| 426 | is used in stringification operations. | ||||||||||||||||||||
| 427 | |||||||||||||||||||||
| 428 | I<Since C<0.01>> | ||||||||||||||||||||
| 429 | |||||||||||||||||||||
| 430 | =over 4 | ||||||||||||||||||||
| 431 | |||||||||||||||||||||
| 432 | =item explain example 1 | ||||||||||||||||||||
| 433 | |||||||||||||||||||||
| 434 | # given: synopsis; | ||||||||||||||||||||
| 435 | |||||||||||||||||||||
| 436 | my $explain = $replace->explain; | ||||||||||||||||||||
| 437 | |||||||||||||||||||||
| 438 | # "hello universe" | ||||||||||||||||||||
| 439 | |||||||||||||||||||||
| 440 | =back | ||||||||||||||||||||
| 441 | |||||||||||||||||||||
| 442 | =cut | ||||||||||||||||||||
| 443 | |||||||||||||||||||||
| 444 | =head2 get | ||||||||||||||||||||
| 445 | |||||||||||||||||||||
| 446 | get() (string) | ||||||||||||||||||||
| 447 | |||||||||||||||||||||
| 448 | The get method returns the subject of the regular expression operation. | ||||||||||||||||||||
| 449 | |||||||||||||||||||||
| 450 | I<Since C<0.01>> | ||||||||||||||||||||
| 451 | |||||||||||||||||||||
| 452 | =over 4 | ||||||||||||||||||||
| 453 | |||||||||||||||||||||
| 454 | =item get example 1 | ||||||||||||||||||||
| 455 | |||||||||||||||||||||
| 456 | # given: synopsis; | ||||||||||||||||||||
| 457 | |||||||||||||||||||||
| 458 | my $get = $replace->get; | ||||||||||||||||||||
| 459 | |||||||||||||||||||||
| 460 | # "hello universe" | ||||||||||||||||||||
| 461 | |||||||||||||||||||||
| 462 | =back | ||||||||||||||||||||
| 463 | |||||||||||||||||||||
| 464 | =cut | ||||||||||||||||||||
| 465 | |||||||||||||||||||||
| 466 | =head2 initial | ||||||||||||||||||||
| 467 | |||||||||||||||||||||
| 468 | initial() (string) | ||||||||||||||||||||
| 469 | |||||||||||||||||||||
| 470 | The initial method returns the unaltered string from the result object which | ||||||||||||||||||||
| 471 | contains information about the results of the regular expression operation. | ||||||||||||||||||||
| 472 | |||||||||||||||||||||
| 473 | I<Since C<0.01>> | ||||||||||||||||||||
| 474 | |||||||||||||||||||||
| 475 | =over 4 | ||||||||||||||||||||
| 476 | |||||||||||||||||||||
| 477 | =item initial example 1 | ||||||||||||||||||||
| 478 | |||||||||||||||||||||
| 479 | # given: synopsis; | ||||||||||||||||||||
| 480 | |||||||||||||||||||||
| 481 | my $initial = $replace->initial; | ||||||||||||||||||||
| 482 | |||||||||||||||||||||
| 483 | # "hello world" | ||||||||||||||||||||
| 484 | |||||||||||||||||||||
| 485 | =back | ||||||||||||||||||||
| 486 | |||||||||||||||||||||
| 487 | =cut | ||||||||||||||||||||
| 488 | |||||||||||||||||||||
| 489 | =head2 last_match_end | ||||||||||||||||||||
| 490 | |||||||||||||||||||||
| 491 | last_match_end() (maybe[within[arrayref, number]]) | ||||||||||||||||||||
| 492 | |||||||||||||||||||||
| 493 | The last_match_end method returns an array of offset positions into the string | ||||||||||||||||||||
| 494 | where the capture(s) stopped matching from the result object which contains | ||||||||||||||||||||
| 495 | information about the results of the regular expression operation. | ||||||||||||||||||||
| 496 | |||||||||||||||||||||
| 497 | I<Since C<0.01>> | ||||||||||||||||||||
| 498 | |||||||||||||||||||||
| 499 | =over 4 | ||||||||||||||||||||
| 500 | |||||||||||||||||||||
| 501 | =item last_match_end example 1 | ||||||||||||||||||||
| 502 | |||||||||||||||||||||
| 503 | # given: synopsis; | ||||||||||||||||||||
| 504 | |||||||||||||||||||||
| 505 | my $last_match_end = $replace->last_match_end; | ||||||||||||||||||||
| 506 | |||||||||||||||||||||
| 507 | # [11, 11] | ||||||||||||||||||||
| 508 | |||||||||||||||||||||
| 509 | =back | ||||||||||||||||||||
| 510 | |||||||||||||||||||||
| 511 | =cut | ||||||||||||||||||||
| 512 | |||||||||||||||||||||
| 513 | =head2 last_match_start | ||||||||||||||||||||
| 514 | |||||||||||||||||||||
| 515 | last_match_start() (maybe[within[arrayref, number]]) | ||||||||||||||||||||
| 516 | |||||||||||||||||||||
| 517 | The last_match_start method returns an array of offset positions into the | ||||||||||||||||||||
| 518 | string where the capture(s) matched from the result object which contains | ||||||||||||||||||||
| 519 | information about the results of the regular expression operation. | ||||||||||||||||||||
| 520 | |||||||||||||||||||||
| 521 | I<Since C<0.01>> | ||||||||||||||||||||
| 522 | |||||||||||||||||||||
| 523 | =over 4 | ||||||||||||||||||||
| 524 | |||||||||||||||||||||
| 525 | =item last_match_start example 1 | ||||||||||||||||||||
| 526 | |||||||||||||||||||||
| 527 | # given: synopsis; | ||||||||||||||||||||
| 528 | |||||||||||||||||||||
| 529 | my $last_match_start = $replace->last_match_start; | ||||||||||||||||||||
| 530 | |||||||||||||||||||||
| 531 | # [6, 6] | ||||||||||||||||||||
| 532 | |||||||||||||||||||||
| 533 | =back | ||||||||||||||||||||
| 534 | |||||||||||||||||||||
| 535 | =cut | ||||||||||||||||||||
| 536 | |||||||||||||||||||||
| 537 | =head2 matched | ||||||||||||||||||||
| 538 | |||||||||||||||||||||
| 539 | matched() (maybe[string]) | ||||||||||||||||||||
| 540 | |||||||||||||||||||||
| 541 | The matched method returns the portion of the string that matched from the | ||||||||||||||||||||
| 542 | result object which contains information about the results of the regular | ||||||||||||||||||||
| 543 | expression operation. | ||||||||||||||||||||
| 544 | |||||||||||||||||||||
| 545 | I<Since C<0.01>> | ||||||||||||||||||||
| 546 | |||||||||||||||||||||
| 547 | =over 4 | ||||||||||||||||||||
| 548 | |||||||||||||||||||||
| 549 | =item matched example 1 | ||||||||||||||||||||
| 550 | |||||||||||||||||||||
| 551 | # given: synopsis; | ||||||||||||||||||||
| 552 | |||||||||||||||||||||
| 553 | my $matched = $replace->matched; | ||||||||||||||||||||
| 554 | |||||||||||||||||||||
| 555 | # "world" | ||||||||||||||||||||
| 556 | |||||||||||||||||||||
| 557 | =back | ||||||||||||||||||||
| 558 | |||||||||||||||||||||
| 559 | =cut | ||||||||||||||||||||
| 560 | |||||||||||||||||||||
| 561 | =head2 named_captures | ||||||||||||||||||||
| 562 | |||||||||||||||||||||
| 563 | named_captures() (hashref) | ||||||||||||||||||||
| 564 | |||||||||||||||||||||
| 565 | The named_captures method returns a hash containing the requested named regular | ||||||||||||||||||||
| 566 | expressions and captured string pairs from the result object which contains | ||||||||||||||||||||
| 567 | information about the results of the regular expression operation. | ||||||||||||||||||||
| 568 | |||||||||||||||||||||
| 569 | I<Since C<0.01>> | ||||||||||||||||||||
| 570 | |||||||||||||||||||||
| 571 | =over 4 | ||||||||||||||||||||
| 572 | |||||||||||||||||||||
| 573 | =item named_captures example 1 | ||||||||||||||||||||
| 574 | |||||||||||||||||||||
| 575 | # given: synopsis; | ||||||||||||||||||||
| 576 | |||||||||||||||||||||
| 577 | my $named_captures = $replace->named_captures; | ||||||||||||||||||||
| 578 | |||||||||||||||||||||
| 579 | # {} | ||||||||||||||||||||
| 580 | |||||||||||||||||||||
| 581 | =back | ||||||||||||||||||||
| 582 | |||||||||||||||||||||
| 583 | =over 4 | ||||||||||||||||||||
| 584 | |||||||||||||||||||||
| 585 | =item named_captures example 2 | ||||||||||||||||||||
| 586 | |||||||||||||||||||||
| 587 | package main; | ||||||||||||||||||||
| 588 | |||||||||||||||||||||
| 589 | use Venus::Replace; | ||||||||||||||||||||
| 590 | |||||||||||||||||||||
| 591 | my $replace = Venus::Replace->new( | ||||||||||||||||||||
| 592 | string => 'hello world', | ||||||||||||||||||||
| 593 | regexp => '(?<locale>world)', | ||||||||||||||||||||
| 594 | substr => 'universe', | ||||||||||||||||||||
| 595 | ); | ||||||||||||||||||||
| 596 | |||||||||||||||||||||
| 597 | my $named_captures = $replace->named_captures; | ||||||||||||||||||||
| 598 | |||||||||||||||||||||
| 599 | # { locale => ["world"] } | ||||||||||||||||||||
| 600 | |||||||||||||||||||||
| 601 | =back | ||||||||||||||||||||
| 602 | |||||||||||||||||||||
| 603 | =cut | ||||||||||||||||||||
| 604 | |||||||||||||||||||||
| 605 | =head2 postmatched | ||||||||||||||||||||
| 606 | |||||||||||||||||||||
| 607 | postmatched() (Maybe[string]) | ||||||||||||||||||||
| 608 | |||||||||||||||||||||
| 609 | The postmatched method returns the portion of the string after the regular | ||||||||||||||||||||
| 610 | expression matched from the result object which contains information about the | ||||||||||||||||||||
| 611 | results of the regular expression operation. | ||||||||||||||||||||
| 612 | |||||||||||||||||||||
| 613 | I<Since C<0.01>> | ||||||||||||||||||||
| 614 | |||||||||||||||||||||
| 615 | =over 4 | ||||||||||||||||||||
| 616 | |||||||||||||||||||||
| 617 | =item postmatched example 1 | ||||||||||||||||||||
| 618 | |||||||||||||||||||||
| 619 | # given: synopsis; | ||||||||||||||||||||
| 620 | |||||||||||||||||||||
| 621 | my $postmatched = $replace->postmatched; | ||||||||||||||||||||
| 622 | |||||||||||||||||||||
| 623 | # "" | ||||||||||||||||||||
| 624 | |||||||||||||||||||||
| 625 | =back | ||||||||||||||||||||
| 626 | |||||||||||||||||||||
| 627 | =cut | ||||||||||||||||||||
| 628 | |||||||||||||||||||||
| 629 | =head2 prematched | ||||||||||||||||||||
| 630 | |||||||||||||||||||||
| 631 | prematched() (Maybe[string]) | ||||||||||||||||||||
| 632 | |||||||||||||||||||||
| 633 | The prematched method returns the portion of the string before the regular | ||||||||||||||||||||
| 634 | expression matched from the result object which contains information about the | ||||||||||||||||||||
| 635 | results of the regular expression operation. | ||||||||||||||||||||
| 636 | |||||||||||||||||||||
| 637 | I<Since C<0.01>> | ||||||||||||||||||||
| 638 | |||||||||||||||||||||
| 639 | =over 4 | ||||||||||||||||||||
| 640 | |||||||||||||||||||||
| 641 | =item prematched example 1 | ||||||||||||||||||||
| 642 | |||||||||||||||||||||
| 643 | # given: synopsis; | ||||||||||||||||||||
| 644 | |||||||||||||||||||||
| 645 | my $prematched = $replace->prematched; | ||||||||||||||||||||
| 646 | |||||||||||||||||||||
| 647 | # "hello " | ||||||||||||||||||||
| 648 | |||||||||||||||||||||
| 649 | =back | ||||||||||||||||||||
| 650 | |||||||||||||||||||||
| 651 | =cut | ||||||||||||||||||||
| 652 | |||||||||||||||||||||
| 653 | =head2 set | ||||||||||||||||||||
| 654 | |||||||||||||||||||||
| 655 | set(string $data) (string) | ||||||||||||||||||||
| 656 | |||||||||||||||||||||
| 657 | The set method sets the subject of the regular expression operation. | ||||||||||||||||||||
| 658 | |||||||||||||||||||||
| 659 | I<Since C<0.01>> | ||||||||||||||||||||
| 660 | |||||||||||||||||||||
| 661 | =over 4 | ||||||||||||||||||||
| 662 | |||||||||||||||||||||
| 663 | =item set example 1 | ||||||||||||||||||||
| 664 | |||||||||||||||||||||
| 665 | # given: synopsis; | ||||||||||||||||||||
| 666 | |||||||||||||||||||||
| 667 | my $set = $replace->set('hello universe'); | ||||||||||||||||||||
| 668 | |||||||||||||||||||||
| 669 | # "hello universe" | ||||||||||||||||||||
| 670 | |||||||||||||||||||||
| 671 | =back | ||||||||||||||||||||
| 672 | |||||||||||||||||||||
| 673 | =cut | ||||||||||||||||||||
| 674 | |||||||||||||||||||||
| 675 | =head1 ERRORS | ||||||||||||||||||||
| 676 | |||||||||||||||||||||
| 677 | This package may raise the following errors: | ||||||||||||||||||||
| 678 | |||||||||||||||||||||
| 679 | =cut | ||||||||||||||||||||
| 680 | |||||||||||||||||||||
| 681 | =over 4 | ||||||||||||||||||||
| 682 | |||||||||||||||||||||
| 683 | =item error: C<error_on_evaluate> | ||||||||||||||||||||
| 684 | |||||||||||||||||||||
| 685 | This package may raise an error_on_evaluate exception. | ||||||||||||||||||||
| 686 | |||||||||||||||||||||
| 687 | B<example 1> | ||||||||||||||||||||
| 688 | |||||||||||||||||||||
| 689 | # given: synopsis; | ||||||||||||||||||||
| 690 | |||||||||||||||||||||
| 691 | my $input = { | ||||||||||||||||||||
| 692 | throw => 'error_on_evaluate', | ||||||||||||||||||||
| 693 | error => 'Exception!', | ||||||||||||||||||||
| 694 | }; | ||||||||||||||||||||
| 695 | |||||||||||||||||||||
| 696 | my $error = $replace->catch('error', $input); | ||||||||||||||||||||
| 697 | |||||||||||||||||||||
| 698 | # my $name = $error->name; | ||||||||||||||||||||
| 699 | |||||||||||||||||||||
| 700 | # "on_evaluate" | ||||||||||||||||||||
| 701 | |||||||||||||||||||||
| 702 | # my $message = $error->message; | ||||||||||||||||||||
| 703 | |||||||||||||||||||||
| 704 | # "Exception!" | ||||||||||||||||||||
| 705 | |||||||||||||||||||||
| 706 | =back | ||||||||||||||||||||
| 707 | |||||||||||||||||||||
| 708 | =head1 OPERATORS | ||||||||||||||||||||
| 709 | |||||||||||||||||||||
| 710 | This package overloads the following operators: | ||||||||||||||||||||
| 711 | |||||||||||||||||||||
| 712 | =cut | ||||||||||||||||||||
| 713 | |||||||||||||||||||||
| 714 | =over 4 | ||||||||||||||||||||
| 715 | |||||||||||||||||||||
| 716 | =item operation: C<("")> | ||||||||||||||||||||
| 717 | |||||||||||||||||||||
| 718 | This package overloads the C<""> operator. | ||||||||||||||||||||
| 719 | |||||||||||||||||||||
| 720 | B<example 1> | ||||||||||||||||||||
| 721 | |||||||||||||||||||||
| 722 | # given: synopsis; | ||||||||||||||||||||
| 723 | |||||||||||||||||||||
| 724 | my $result = "$replace"; | ||||||||||||||||||||
| 725 | |||||||||||||||||||||
| 726 | # "hello universe" | ||||||||||||||||||||
| 727 | |||||||||||||||||||||
| 728 | B<example 2> | ||||||||||||||||||||
| 729 | |||||||||||||||||||||
| 730 | # given: synopsis; | ||||||||||||||||||||
| 731 | |||||||||||||||||||||
| 732 | my $result = "$replace, $replace"; | ||||||||||||||||||||
| 733 | |||||||||||||||||||||
| 734 | # "hello universe, hello universe" | ||||||||||||||||||||
| 735 | |||||||||||||||||||||
| 736 | =back | ||||||||||||||||||||
| 737 | |||||||||||||||||||||
| 738 | =over 4 | ||||||||||||||||||||
| 739 | |||||||||||||||||||||
| 740 | =item operation: C<(.)> | ||||||||||||||||||||
| 741 | |||||||||||||||||||||
| 742 | This package overloads the C<.> operator. | ||||||||||||||||||||
| 743 | |||||||||||||||||||||
| 744 | B<example 1> | ||||||||||||||||||||
| 745 | |||||||||||||||||||||
| 746 | # given: synopsis; | ||||||||||||||||||||
| 747 | |||||||||||||||||||||
| 748 | my $result = $replace . ', welcome'; | ||||||||||||||||||||
| 749 | |||||||||||||||||||||
| 750 | # "hello universe, welcome" | ||||||||||||||||||||
| 751 | |||||||||||||||||||||
| 752 | =back | ||||||||||||||||||||
| 753 | |||||||||||||||||||||
| 754 | =over 4 | ||||||||||||||||||||
| 755 | |||||||||||||||||||||
| 756 | =item operation: C<(eq)> | ||||||||||||||||||||
| 757 | |||||||||||||||||||||
| 758 | This package overloads the C<eq> operator. | ||||||||||||||||||||
| 759 | |||||||||||||||||||||
| 760 | B<example 1> | ||||||||||||||||||||
| 761 | |||||||||||||||||||||
| 762 | # given: synopsis; | ||||||||||||||||||||
| 763 | |||||||||||||||||||||
| 764 | my $result = $replace eq 'hello universe'; | ||||||||||||||||||||
| 765 | |||||||||||||||||||||
| 766 | # 1 | ||||||||||||||||||||
| 767 | |||||||||||||||||||||
| 768 | =back | ||||||||||||||||||||
| 769 | |||||||||||||||||||||
| 770 | =over 4 | ||||||||||||||||||||
| 771 | |||||||||||||||||||||
| 772 | =item operation: C<(ne)> | ||||||||||||||||||||
| 773 | |||||||||||||||||||||
| 774 | This package overloads the C<ne> operator. | ||||||||||||||||||||
| 775 | |||||||||||||||||||||
| 776 | B<example 1> | ||||||||||||||||||||
| 777 | |||||||||||||||||||||
| 778 | # given: synopsis; | ||||||||||||||||||||
| 779 | |||||||||||||||||||||
| 780 | my $result = $replace ne 'Hello universe'; | ||||||||||||||||||||
| 781 | |||||||||||||||||||||
| 782 | # 1 | ||||||||||||||||||||
| 783 | |||||||||||||||||||||
| 784 | =back | ||||||||||||||||||||
| 785 | |||||||||||||||||||||
| 786 | =over 4 | ||||||||||||||||||||
| 787 | |||||||||||||||||||||
| 788 | =item operation: C<(qr)> | ||||||||||||||||||||
| 789 | |||||||||||||||||||||
| 790 | This package overloads the C<qr> operator. | ||||||||||||||||||||
| 791 | |||||||||||||||||||||
| 792 | B<example 1> | ||||||||||||||||||||
| 793 | |||||||||||||||||||||
| 794 | # given: synopsis; | ||||||||||||||||||||
| 795 | |||||||||||||||||||||
| 796 | my $result = 'hello universe, welcome' =~ qr/$replace/; | ||||||||||||||||||||
| 797 | |||||||||||||||||||||
| 798 | # 1 | ||||||||||||||||||||
| 799 | |||||||||||||||||||||
| 800 | =back | ||||||||||||||||||||
| 801 | |||||||||||||||||||||
| 802 | =over 4 | ||||||||||||||||||||
| 803 | |||||||||||||||||||||
| 804 | =item operation: C<(~~)> | ||||||||||||||||||||
| 805 | |||||||||||||||||||||
| 806 | This package overloads the C<~~> operator. | ||||||||||||||||||||
| 807 | |||||||||||||||||||||
| 808 | B<example 1> | ||||||||||||||||||||
| 809 | |||||||||||||||||||||
| 810 | # given: synopsis; | ||||||||||||||||||||
| 811 | |||||||||||||||||||||
| 812 | my $result = $replace ~~ 'hello universe'; | ||||||||||||||||||||
| 813 | |||||||||||||||||||||
| 814 | # 1 | ||||||||||||||||||||
| 815 | |||||||||||||||||||||
| 816 | =back | ||||||||||||||||||||
| 817 | |||||||||||||||||||||
| 818 | =head1 AUTHORS | ||||||||||||||||||||
| 819 | |||||||||||||||||||||
| 820 | Awncorp, C<awncorp@cpan.org> | ||||||||||||||||||||
| 821 | |||||||||||||||||||||
| 822 | =cut | ||||||||||||||||||||
| 823 | |||||||||||||||||||||
| 824 | =head1 LICENSE | ||||||||||||||||||||
| 825 | |||||||||||||||||||||
| 826 | Copyright (C) 2000, Awncorp, C<awncorp@cpan.org>. | ||||||||||||||||||||
| 827 | |||||||||||||||||||||
| 828 | This program is free software, you can redistribute it and/or modify it under | ||||||||||||||||||||
| 829 | the terms of the Apache license version 2.0. | ||||||||||||||||||||
| 830 | |||||||||||||||||||||
| 831 | =cut | ||||||||||||||||||||