Skip to content

Instantly share code, notes, and snippets.

@jyotty
Created November 22, 2011 18:17
Show Gist options
  • Select an option

  • Save jyotty/1386420 to your computer and use it in GitHub Desktop.

Select an option

Save jyotty/1386420 to your computer and use it in GitHub Desktop.
I can't speak for what I was thinking at the time.
if (!grep { $action eq $_ } @Controller::actions) {
unshift(@parts, $action, 404);
$action = 'error';
}
# …
my $sub;
{
no strict 'refs';
$sub = *{"Controller::$action"}{CODE};
}
#…
package Controller;
our @actions = do {
no strict 'refs';
grep { exists &{$_} && !/^_/ } keys %{__PACKAGE__.'::'};
};
sub error { … } # &c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment