| Next | Making Programs Faster | 59 |
Digression: While grovelling over the POD parser code, I wandered in here:
sub append {
my $self = shift;
local *ptree = $self;
for (@_) {
next unless length;
if (@ptree and !(ref $ptree[-1]) and !(ref $_)) {
$ptree[-1] .= $_;
}
else {
push @ptree, $_;
}
}
}
A Pod::ParseTree object is basically an array of strings and objects
Normally, we can use push to append a new item to the array



But if the last element of the array is a string,
and the thing we're appending is also a string
then we can concatenate the two strings instead

| Next | ![]() |
Copyright © 2003 M. J. Dominus |