hurricup has asked for the wisdom of the Perl Monks concerning the following question:
Hi there!
I've decided to create a useful module to generate class properties. I've done it and it works fine on perl 5.16.3+, but older perls don't want to compile it.
Module can be found here.
The main idea is generating lvalue properties using tie and closure:
sub get_property { my( $getter, $setter ) = @_; require Class::Property::RW::Custom; my $dummy; my $wrapper = tie $dummy, 'Class::Property::RW::Custom', $getter, +$setter; return sub: lvalue { $wrapper->set_object(shift); return $dummy; # <= here is error in older perls }; }
Error message is not quite clear and i don't understand, what is wrong. Please, help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: lvalues in perl prior to 5.16.3 throws "Can't modify reference constructor in lvalue subroutine return"
by ikegami (Patriarch) on Jan 22, 2015 at 15:32 UTC | |
by hurricup (Pilgrim) on Jan 23, 2015 at 05:38 UTC | |
|
Re: lvalues in perl prior to 5.16.3 throws "Can't modify reference constructor in lvalue subroutine return"
by choroba (Cardinal) on Jan 22, 2015 at 11:00 UTC | |
|
Re: lvalues in perl prior to 5.16.3 throws "Can't modify reference constructor in lvalue subroutine return"
by LanX (Saint) on Jan 22, 2015 at 11:17 UTC | |
|
Re: lvalues in perl prior to 5.16.3 throws "Can't modify reference constructor in lvalue subroutine return"
by LanX (Saint) on Jan 22, 2015 at 11:54 UTC |