58
|
1632 |
804 |
429 |
length $text and $text =~ s/ $expr_expr /my $substitute = $rules{$1};
if (not ref $substitute) {
$substitute;
}
elsif (ref $substitute eq 'CODE') {
&{$substitute;}();
}
else {
croak("Unknown type of substitution rule: '${substitute}'");
};/egsx or $text =~ s[ $block_expr ][my $substitute = $rules{$1 . '{}'};
my $contents = $2;
if (not ref $substitute) {
$substitute =~ s/\*/$contents/g;
$substitute;
}
elsif (ref $substitute eq 'HASH') {
$$substitute{$contents};
}
elsif (ref $substitute eq 'CODE') {
&{$substitute;}($contents);
}
else {
croak("Unknown type of substitution rule: '${substitute}'");
};]egsx |