Skip to content

Instantly share code, notes, and snippets.

@anazawa
Created April 22, 2012 20:34
Show Gist options
  • Select an option

  • Save anazawa/2466717 to your computer and use it in GitHub Desktop.

Select an option

Save anazawa/2466717 to your computer and use it in GitHub Desktop.
呼び出し可能なサブルーチンを限定する
{
my %foo = (
start => 0,
template => 0,
entries => 0,
filter => 1,
skip => 1,
interpolate => 1,
head => 1,
sort => 1,
date => 1,
story => 1,
foot => 1,
last => 1,
end => 1,
);
sub _foo {
my $sub = shift;
$sub =~ s/.*:://o;
$foo{$sub};
}
}
sub new {
my $sub = ( caller(1) )[3];
croak unless _foo( $sub );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment