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