sub call_twice { my $func = shift; &$func("first"); $func->("second"); } sub foo { print "foo: @_\n" } call_twice(\&foo); call_twice(sub { print "bar: @_\n" });
-- Chip Salzenberg, Free-Floating Agent of Chaos
In reply to Re: Passing subroutines as arguments
by chip
in thread Passing subroutines as arguments
by mvaline
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |