I suspect that may not be flexible enough to meet your needs, though...my $g = Games::Grid->new( border => 4, width => sub { $_[0]/4 }, height => sub { $_[0] }, fill => '=', ); { my $W = $self->{terminal}->{_co}; my $H = $self->{terminal}->{_li}; $self->terminal->{WIDTH} = $config{width}->($W); $self->terminal->{HEIGHT} = $config{height}->($H); }
How about using package variables for $W and $H, instead of lexical variables?
my $g = Games::Grid->new( border => 4, width => sub { $terminal::W/4 }, height => sub { $terminal::H }, fill => '=', ); { $terminal::W = $self->{terminal}->{_co}; $terminal::H = $self->{terminal}->{_li}; $self->terminal->{WIDTH} = $config{width}->(); $self->terminal->{HEIGHT} = $config{height}->(); }
In reply to Re: Algebraic Hash Configuration via Delayed Closure?
by chipmunk
in thread Algebraic Hash Configuration via Delayed Closure?
by princepawn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |