$ perl -MCGI -e 'sub curry_method{ my ($o, $m) = @_; sub { $o->$m(@_) } } $c = CGI->new; $p = curry_method($c, 'p'); print $p->("Hello World"), "\n"'
Hello World
####
package Bridge::Simple;
use strict;
use Carp;
sub new {
my ($class, $obj, $mapping) = @_;
my $self = {};
@{$self}{keys %$mapping} =
map { my $meth = $_;
sub { $obj->$meth(@_) }
} values %$mapping;
bless $self, $class;
}
sub AUTOLOAD {
my $self = shift;
our $AUTOLOAD =~ s/.*:://;
croak "no method $AUTOLOAD" unless exists $self->{$AUTOLOAD};
goto $self->{$AUTOLOAD};
}
1;