| 1 | package String::BufferStack; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Carp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 5 | our $VERSION; $VERSION = "1.16"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | String::BufferStack - Nested buffers for templating systems | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | my $stack = String::BufferStack->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | $stack->push( filter => sub {return uc shift} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | $stack->append("content"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | $stack->flush_output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =head1 DESCRIPTION | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | C<String::BufferStack> provides a framework for storing nested | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | buffers. By default, all of the buffers flow directly to the output | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | method, but individual levels of the stack can apply filters, or store | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | their output in a scalar reference. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | =head1 METHODS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | =head2 new PARAMHASH | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | Creates a new buffer stack and returns it. Possible arguments include: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | =item prealoc | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | Preallocate this many bytes in the output buffer. This can reduce | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | reallocations, and thus speed up appends. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | =item out_method | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | The method to call when output trickles down to the bottom-most buffer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | and is flushed via L<flush_output>. The default C<out_method> prints | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | the content to C<STDOUT>. This method will always be called with | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | non-undef, non-zero length content. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | =item use_length | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | Calculate length of each buffer as it is built. This imposes a | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | significant runtime cost, so should be avoided if at all possible. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | Defaults to off. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | ▶ | sub new { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.2
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 6 | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | my %args = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 6 | ▶ | my $output = " "x($args{prealloc} || 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'prealloc'} || 0
MC/DC0%0/1
$args{'prealloc'} || 0
$args{'prealloc'}
Truth table50%1/2
A
A= $args{'prealloc'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 6 | $output = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | return bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | stack => [], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | top => undef, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | output => \$output, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | out_method => $args{out_method} || sub { print STDOUT @_ }, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | pre_appends => {}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | use_length => $args{use_length}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 6 | ▶ | }, $class; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$args{'out_method'} || sub {
print STDOUT @_;
}
MC/DC0%0/2
$args{'out_method'} || sub {
print STDOUT @_;
}
$args{'out_method'}
sub {
print STDOUT @_;
}
Truth table66%2/3
A || B
A= $args{'out_method'}B= sub {
print STDOUT @_;
}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | =head2 push PARAMHASH | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | Pushes a new frame onto the buffer stack. By default, the output from | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | this new frame connects to the input of the previous frame. There are | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | a number of possible options: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | =over | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | =item buffer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | A string reference, into which the output from this stack frame will | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | appear. By default, this is the input buffer of the previous frame. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | =item private | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | If a true value is passed for C<private>, it creates a private string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | reference, and uses that as the buffer -- this is purely for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | convenience. That is, the following blocks are equivilent: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | my $buffer = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | $stack->push( buffer => \$buffer ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # ... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | $stack->pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | print $buffer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $stack->push( private => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # ... | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | print $stack->pop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | =item pre_append | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | A callback, which will be called with a reference to the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | C<String::BufferStack> object, and the arguments to append, whenever | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | this stack frame has anything appended to the input buffer, directly | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | or indirectly. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | Within the context of the pre-append callback, L</append>, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | L</direct_append>, and L</set_pre_append> function on the frame the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | pre-append is attached to, not the topmost trame. Using L</append> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | within the pre-append callback is not suggested; use | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | L</direct_append> instead. L</set_pre_append> can be used to alter or | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | remove the pre-append callback itself -- this is not uncommon, in | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | the case where the first append is the only one which needs be watched | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | for, for instance. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | =item filter | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | A callback, used to process data which is appended to the stack frame. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | By default, filters are lazy, being called only when a frame is | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | popped. They can be forced at any time by calling L</flush_filters>, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | however. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | =back | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 19 | ▶ | sub push { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push: called CC=8 SCAR=22.3
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 19 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | my $frame = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | buffer => $self->{top} ? $self->{top}{pre_filter} : $self->{output}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | @_ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 19 | ▶ | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 19 | my $filter = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 19 | my $buffer = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 19 | ▶ | $frame->{buffer} = \$buffer if delete $frame->{private}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | $frame->{length} = (defined ${$frame->{buffer}}) ? CORE::length(${$frame->{buffer}}) : 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 19 | ▶ | if $self->{use_length} or $frame->{use_length}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$self->{"use_length"} or $frame->{"use_length"}
MC/DC0%0/2
$self->{"use_length"} or $frame->{"use_length"}
$self->{"use_length"}
$frame->{"use_length"}
Truth table33%1/3
A or B
A= $self->{"use_length"}B= $frame->{"use_length"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 19 | ▶ | $frame->{pre_filter} = $frame->{filter} ? \$filter : $frame->{buffer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 19 | $self->{top} = $frame; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 19 | local $self->{local_frame} = $frame; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 19 | ▶ | $self->set_pre_append(delete $frame->{pre_append}) if defined $frame->{pre_append}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 19 | CORE::push(@{$self->{stack}}, $frame); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | =head2 depth | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | Returns the current depth of the stack. This starts at 0, when no | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | frames have been pushed, and increases by one for each frame pushed. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 14 | ▶ | sub depth { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
depth: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 14 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 14 | return scalar @{$self->{stack}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | =head2 append STRING [, STRING, ...] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | Appends the given strings to the input side of the topmost buffer. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | This will call all pre-append hooks attached to it, as well. Note | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | that if the frame has a filter, the filter will not immediately run, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | but will be delayed until the frame is L</pop>'d, or L</flush_filters> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | is called. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | When called with no frames on the stack, appends the stringins | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | directly to the L</output_buffer>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 49 | ▶ | sub append { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
append: called CC=11 SCAR=24.1
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 49 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 49 | ▶ | my $frame = $self->{local_frame} || $self->{top}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'local_frame'} || $self->{'top'}
MC/DC50%1/2
$self->{'local_frame'} || $self->{'top'}
$self->{'local_frame'}
$self->{'top'}
Truth table66%2/3
A || B
A= $self->{'local_frame'}B= $self->{'top'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 49 | ▶ | if ($frame) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 31 | my $ref = $frame->{pre_filter}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 31 | ▶ | if (exists $self->{pre_appends}{$frame->{buffer}} and not $frame->{filter}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $self->{"pre_appends"}{$frame->{"buffer"}} and not $frame->{"filter"}
MC/DC100%2/2
exists $self->{"pre_appends"}{$frame->{"buffer"}} and not $frame->{"filter"}
exists $self->{"pre_appends"}{$frame->{"buffer"}}
not $frame->{"filter"}
Truth table100%3/3
A and not(B)
A= exists $self->{"pre_appends"}{$frame->{"buffer"}}B= not $frame->{"filter"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | # This is an append to the output buffer, signal all pre_append hooks for it | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 8 | for my $frame (@{$self->{pre_appends}{$frame->{buffer}}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 11 | ▶ | die unless $frame->{pre_append}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 11 | local $self->{local_frame} = $frame; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 11 | $frame->{pre_append}->($self, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 31 | for (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 31 | ▶ | $$ref .= $_ if defined; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 18 | my $ref = $self->{output}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 18 | for (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 18 | ▶ | $$ref .= $_ if defined; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | =head2 direct_append STRING [, STRING, ...] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | Similar to L</append>, but appends the strings to the output side of | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | the frame, skipping pre-append callbacks and filters. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | When called with no frames on the stack, appends the strings | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | directly to the L</output_buffer>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | ▶ | sub direct_append { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
direct_append: called CC=5 SCAR=17.8
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 2 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 2 | ▶ | my $frame = $self->{local_frame} || $self->{top}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'local_frame'} || $self->{'top'}
MC/DC0%0/2
$self->{'local_frame'} || $self->{'top'}
$self->{'local_frame'}
$self->{'top'}
Truth table33%1/3
A || B
A= $self->{'local_frame'}B= $self->{'top'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | ▶ | my $ref = $frame ? $frame->{buffer} : $self->{output}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | for (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | ▶ | $$ref .= $_ if defined; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | =head2 pop | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | Removes the topmost frame on the stack, flushing the topmost filters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | in the process. Returns the output buffer of the frame -- note that | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | this may not contain only strings appended in the current frame, but | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | also those from before, as a speed optimization. That is: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | $stack->append("one"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | $stack->push; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | $stack->append(" two"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | $stack->pop; # returns "one two" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | This operation is a no-op if there are no frames on the stack. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 20 | ▶ | sub pop { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pop: called CC=3 SCAR=11.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 20 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 20 | ▶ | return unless $self->{top}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 18 | $self->filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 18 | my $frame = CORE::pop(@{$self->{stack}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 18 | local $self->{local_frame} = $frame; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 18 | $self->set_pre_append(undef); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 18 | ▶ | $self->{top} = @{$self->{stack}} ? $self->{stack}[-1] : undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 18 | return ${$frame->{buffer}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | =head2 set_pre_append CALLBACK | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | Alters the pre-append callback on the topmost frame. The callback | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | will be called before text is appended to the input buffer of the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | frame, and will be passed the C<String::BufferStack> and the arguments | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | to L</append>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 29 | ▶ | sub set_pre_append { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_pre_append: called CC=8 SCAR=21.2
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 29 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 29 | my $hook = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 29 | ▶ | my $frame = $self->{local_frame} || $self->{top}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'local_frame'} || $self->{'top'}
MC/DC0%0/2
$self->{'local_frame'} || $self->{'top'}
$self->{'local_frame'}
$self->{'top'}
Truth table33%1/3
A || B
A= $self->{'local_frame'}B= $self->{'top'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 29 | ▶ | return unless $frame; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 29 | ▶ | if ($hook and not $frame->{pre_append}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$hook and not $frame->{"pre_append"}
MC/DC50%1/2
$hook and not $frame->{"pre_append"}
$hook
not $frame->{"pre_append"}
Truth table66%2/3
A and not(B)
A= $hookB= not $frame->{"pre_append"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 7 | CORE::push(@{$self->{pre_appends}{$frame->{buffer}}}, $frame); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | ▶ | } elsif (not $hook and $frame->{pre_append}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not $hook and $frame->{"pre_append"}
MC/DC50%1/2
not $hook and $frame->{"pre_append"}
not $hook
$frame->{"pre_append"}
Truth table66%2/3
not(A) and B
A= not $hookB= $frame->{"pre_append"}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | $self->{pre_appends}{ $frame->{buffer} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 7 | = [ grep { $_ ne $frame } @{ $self->{pre_appends}{ $frame->{buffer} } } ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | delete $self->{pre_appends}{ $frame->{buffer} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 7 | ▶ | unless @{ $self->{pre_appends}{ $frame->{buffer} } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 29 | $frame->{pre_append} = $hook; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | =head2 set_filter FILTER | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | Alters the filter on the topmost frame. Doing this flushes the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | filters on the topmost frame. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 4 | ▶ | sub set_filter { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_filter: called CC=6 SCAR=17.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 4 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 4 | my $filter = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 4 | ▶ | return unless $self->{top}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 4 | $self->filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 4 | ▶ | if (defined $self->{top}{filter} and not defined $filter) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $self->{"top"}{"filter"} and not defined $filter
MC/DC100%2/2
defined $self->{"top"}{"filter"} and not defined $filter
defined $self->{"top"}{"filter"}
not defined $filter
Truth table100%3/3
A and not(B)
A= defined $self->{"top"}{"filter"}B= not defined $filter
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # Removing a filter, flush, then in = out | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1 | $self->{top}{pre_filter} = $self->{top}{buffer}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ▶ | } elsif (not defined $self->{top}{filter} and defined $filter) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
not defined $self->{"top"}{"filter"} and defined $filter
MC/DC100%2/2
not defined $self->{"top"}{"filter"} and defined $filter
not defined $self->{"top"}{"filter"}
defined $filter
Truth table100%3/3
not(A) and B
A= not defined $self->{"top"}{"filter"}B= defined $filter
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # Adding a filter, add a pre_filter stage | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | my $pre_filter = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | $self->{top}{pre_filter} = \$pre_filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 4 | $self->{top}{filter} = $filter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | =head2 filter | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | Filters the topmost stack frame, if it has outstanding unfiltered | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | data. This will propagate content to lower frames, possibly calling | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | their pre-append hooks. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 37 | ▶ | sub filter { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filter: called CC=7 SCAR=19.5
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 37 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 37 | ▶ | my $frame = shift || $self->{top}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
shift() || $self->{'top'}
MC/DC100%2/2
shift() || $self->{'top'}
shift()
$self->{'top'}
Truth table100%3/3
A || B
A= shift()B= $self->{'top'}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 37 | ▶ | return unless $frame and $frame->{filter} and CORE::length(${$frame->{pre_filter}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$frame and $frame->{"filter"} and CORE::length ${$frame->{"pre_filter"};}
$frame and $frame->{"filter"}
MC/DC100%3/3
$frame and $frame->{"filter"} and CORE::length ${$frame->{"pre_filter"};}
$frame
$frame->{"filter"}
CORE::length ${$frame->{"pre_filter"};}
Truth table100%4/4
A and B and C
A= $frameB= $frame->{"filter"}C= CORE::length ${$frame->{"pre_filter"};}
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # We remove the input before we shell out to the filter, so we | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | # don't get into infinite loops. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 13 | my $input = ${$frame->{pre_filter}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 13 | ${$frame->{pre_filter}} = ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 13 | my $output = $frame->{filter}->($input); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 13 | ▶ | if (exists $self->{pre_appends}{$frame->{buffer}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | for my $frame (@{$self->{pre_appends}{$frame->{buffer}}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 1 | local $self->{local_frame} = $frame; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 1 | $frame->{pre_append}->($self, $output); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 13 | ${$frame->{buffer}} .= $output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | =head2 flush | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | If there are no frames on the stack, calls L</flush_output>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | Otherwise, calls L</flush_filters>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 9 | ▶ | sub flush { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 9 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | # Flushing with no stack flushes the output | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 9 | ▶ | return $self->flush_output unless $self->depth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | # Otherwise it just flushes the filters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 3 | $self->flush_filters; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | =head2 flush_filters | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | Flushes all filters. This does not flush output from the output | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | buffer; see L</flush_output>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 18 | ▶ | sub flush_filters { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush_filters: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 18 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | # Push content through filters -- reverse so the top one is first | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 18 | for my $frame (reverse @{$self->{stack}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 13 | $self->filter($frame); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | =head2 buffer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | Returns the contents of the output buffer of the topmost frame; if | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | there are no frames, returns the output buffer. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 59 | ▶ | sub buffer { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
buffer: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 59 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 59 | ▶ | return $self->{top} ? ${$self->{top}{buffer}} : ${$self->{output}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | =head2 buffer_ref | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | Returns a reference to the output buffer of the topmost frame; if | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | there are no frames, returns a reference to the output buffer. Note | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | that adjusting this skips pre-append and filter hooks. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub buffer_ref { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
buffer_ref: not called CC=2 SCAR=17.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | return $self->{top} ? $self->{top}{buffer} : $self->{output}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | =head2 length | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | If C<use_length> was enabled in the buffer stack's constructor, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | returns the number of characters appended to the current frame; if | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | there are no frames, returns the length of the output buffer. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | If C<use_length> was not enabled, warns and returns 0. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | sub length { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
length: not called CC=6 SCAR=37.4
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | carp("String::BufferStack object didn't enable use_length") and return 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | unless $self->{use_length} or ($self->{top} and $self->{top}{use_length}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/11
$self->{'use_length'} || $self->{'top'} && $self->{'top'}{'use_length'} || carp(q[String::BufferStack object didn't enable use_length]) && (return 0)
$self->{"use_length"} or $self->{"top"} and $self->{"top"}{"use_length"}
$self->{"top"} and $self->{"top"}{"use_length"}
carp("String::BufferStack object didn't enable use_length") and return 0
MC/DC0%0/4
$self->{'use_length'} || $self->{'top'} && $self->{'top'}{'use_length'} || carp(q[String::BufferStack object didn't enable use_length]) && (return 0)
$self->{"use_length"}
$self->{"top"}
$self->{"top"}{"use_length"}
carp("String::BufferStack object didn't enable use_length")
Truth table0%0/6
A or B and C || D
A= $self->{"use_length"}B= $self->{"top"}C= $self->{"top"}{"use_length"}D= carp("String::BufferStack object didn't enable use_length")
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | ▶ | return $self->{top} ? CORE::length(${$self->{top}{buffer}}) - $self->{top}{length} : CORE::length(${$self->{output}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | =head2 flush_output | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | Flushes all filters using L</flush_filters>, then flushes output from | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | the output buffer, using the configured L</out_method>. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 7 | ▶ | sub flush_output { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flush_output: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 7 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 7 | $self->flush_filters; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | # Look at what we have at the end | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 7 | ▶ | return unless CORE::length(${$self->{output}}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 5 | $self->{out_method}->(${$self->{output}}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 5 | ${$self->{output}} = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 5 | return ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | =head2 output_buffer | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | Returns the pending output buffer, which sits below all existing | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | frames. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 39 | ▶ | sub output_buffer { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_buffer: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 39 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 39 | return ${$self->{output}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | =head2 output_buffer_ref | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | Returns a reference to the pending output buffer, allowing you to | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | modify it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 4 | ▶ | sub output_buffer_ref { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_buffer_ref: called CC=1 SCAR=0.0
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 4 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 4 | return $self->{output}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | =head2 clear | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | Clears I<all> buffers in the stack, including the output buffer. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 10 | ▶ | sub clear { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 10 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 10 | ${$self->{output}} = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 10 | ${$_->{pre_filter}} = ${$_->{buffer}} = "" for @{$self->{stack}}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 10 | return ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | =head2 clear_top | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | Clears the topmost buffer in the stack; if there are no frames on the | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | stack, clears the output buffer. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | ▶ | sub clear_top { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_top: called CC=2 SCAR=6.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 2 | ▶ | if ($self->{top}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | ${$self->{top}{pre_filter}} = ${$self->{top}{buffer}} = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } else { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | ${$self->{output}} = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | return ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | =head2 out_method [CALLBACK] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | Gets or sets the output method callback, which is given content from | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | the pending output buffer, which sits below all frames. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | ▶ | sub out_method { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
out_method: not called CC=2 SCAR=17.9
Pod
documented
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | $self->{out_method} = shift if @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | return $self->{out_method}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | =head1 SEE ALSO | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | Many concepts were originally taken from L<HTML::Mason>'s internal | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | buffer stack. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | =head1 AUTHORS | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | Alex Vandiver C<< alexmv@bestpractical.com >> | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | =head1 LICENSE | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | Copyright 2008-2009, Best Practical Solutions. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | This package is distributed under the same terms as Perl itself. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | =cut | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 5 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||