package Experimental::Partial; use base 'Exporter'; our @EXPORT = qw(partial); sub partial{ my $sub = shift; my $arity = shift; return _make($sub, $arity); } sub _make{ my $sub = shift; my $arity = shift; my @buff = @_; my @caller = caller; ($caller[0] eq 'Experimental::Partial') or die sprintf('invalid caller "%s"', $caller[0]); return sub{ my @n_buff = (@buff, @_); if(scalar @n_buff < $arity){ return _make($sub, $arity, @n_buff); }else{ return $sub->(@n_buff); } }; } 1;