Please read my above explanation for what I am doing here.
I am changing the problem around to make it easier to maintain and expand. If you really need to have compact code, you can change the &replace sub like this:
my %replaces = (
email => sub { "<a href=mailto:'$_[0]'>$_[1]</a>" },
url => sub { "<a href='$_[0]'>$_[1]</a>'" },
# etc etc etc
);
sub replace {
my ($tag,$attr,$content) = @_;
$attr ||= $content;
return $replaces{$tag}->($attr,$content);
}
I was merely trying to make the code as clean and clear as I could.
--
Joost downtime n. The period during which a system
is error-free and immune from user input.
|