sub input { my ( $c) = @_; ...; &$c($value ); } sub process1 { my ($input, $c) = @_; ...; &$c($result); } sub process2 { my ($input, $c) = @_; ...; &$c($result); } sub output { my ($result ) = @_; ...; } input( sub { process1(@_, sub { process2(@_, \&output ) } ) } );