BEGIN { # Auto-magically generate a number of similar functions without actually # writing them down one-by-one. This makes consistent changes much easier, but # you need perl wizardry level +10 to understand how it works... # # Added wizardry points are gained by this module beeing a parent class to # all other web modules, so this auto-generated functions are subclassed into # every child. my @stdFuncs = qw(prefilter postauthfilter postfilter defaultwebdata late_defaultwebdata task loginitem logoutitem sessionrefresh preconnect prerender lateprerender cleanup authcheck logstart logend logdatadelivery logwebsocket logrequestfinished logstacktrace remotelog sitemap firewall fastredirect); # -- Deep magic begins here... for my $f (@stdFuncs){ #print STDERR "Function " . __PACKAGE__ . "::register_$f will call add_$f\n"; no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict) *{__PACKAGE__ . "::register_$f"} = sub ($arg1, $arg2) { my $funcname = "add_$f"; confess("No function name specified") unless defined($funcname); $arg1->{server}->$funcname($arg1, $arg2); }; } # ... and ends here }