Thread Decorator in Perl?
(18 answers)
Opened by Ronnie at 2008-10-08 16:45
ONTOPIC:
Nach einigem experimentieren empfehle ich abschließend die Verwendung von Sub::Identify und Sub::Install: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 #!/usr/bin/perl use strict; use warnings; use Sub::Identify; use Sub::Install; sub hello_world { my $from = shift || 'who?!'; return "Hello World from " . $from; } sub decorate_h1 { my $sub = shift; my $subname = Sub::Identify::sub_name( $sub ); Sub::Install::reinstall_sub({ code => sub { my @args = @_; return "<h1>" . $sub->(@args) . "</h1>" }, as => $subname, }); return; } decorate_h1(\&hello_world); print hello_world('Perl!'), "\n"; |