Skip to content

Instantly share code, notes, and snippets.

@shelling
Created May 7, 2010 18:05
Show Gist options
  • Select an option

  • Save shelling/393791 to your computer and use it in GitHub Desktop.

Select an option

Save shelling/393791 to your computer and use it in GitHub Desktop.
content_for() in Perl
sub content_for {
my ($tag, $params, $content) = @_;
my $res = "<$tag";
for (keys %{$params}) {
$res .= " $_=$params->{$_}";
}
$res .= ">\n";
if (ref($content) ~~ /CODE/) {
$res .= $content->();
} else {
$res .= $content;
}
$res .= "\n</$tag>\n";
return $res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment