muah haha
Tuesday, September 12, 2000, at 05:37PM
By Eric Richardson
Perl likes me. No matter how crazy of an idea I can come up with, it'll let it work. Today's fun game was to overload a sub with the option of still calling the original sub. Guess what; it's not only possible, but even easy.
The following code does my wishes flawlessly:
my $qual = qualify_to_ref("eThreads::viewer::view_post",caller);
$vp_ref = *{$qual}{CODE};
no strict 'refs';
*{qualify("eThreads::viewer::view_post",caller)} = &view_post;
sub view_post {return sub {
my $class = shift;
my %post = @_;
unshift @_, $class;
if ($post{child_of}) {
&$vp_ref;
}
}}
I apologize for the lack of tabbing, but I'm too lazy to work that out right now.
All in all, a fun little exercise.