#!perl
use strict;
use warnings;
{
package Class;
sub new {
my $pkg = shift;
bless {@_}, $pkg
}
sub property {
my $self = shift;
return $self->{property} unless @_;
$self->{property} = shift;
}
}
{
package Closure;
sub new{
my $instance = { @_ };
return sub{
my $property = shift;
return $instance->{$property} unless @_;
$instance->{$property} = shift;
}
}
}
{
my $o = Class->new;
$o->property('dan');
warn $o->property;
my $c = Closure::new;
$c->(property => 'kogai');
warn $c->('property');
}