This seems the easiest way to me…
use 5.010; use strict; use warnings; { package Test; use Moose; my $prepend = '/some_string/'; has _appended => (is => 'rw', init_arg => 'appended'); sub appended { $prepend . shift->_appended(@_) } } my $t = Test->new(appended => "this_is_appended_string"); say $t->appended; $t->appended('another_string'); say $t->appended;
In reply to Re: Prepend a Moose attribute when changed
by tobyink
in thread Prepend a Moose attribute when changed
by FryingFinn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |