sub compose($$) { my ($f, $g) = @_; sub { $f->( $g->(@_) ) } } sub id { @_ }; # identity function my $composite_fn = reduce {compose($a,$b)} @func_pipeline, \&id;