How can I create a Perl subroutine that accepts more than one block?
问题 With prototypes, you can create a subroutine that accepts a block of code as its first parameter: sub example (&) { my $code_ref = shift; $code_ref->(); } example { print "Hello\n" }; How can I do the same thing, but with more than one block of code? I want to use blocks of codes, not variables or sub { ... } . This does not work: sub example2 (&&) { my $code_ref = shift; my $code_ref2 = shift; $code_ref->(); $code_ref2->(); } example2 { print "One\n" } { print "Hello\n" }; It gives this