If pre and post are always executed directly after eachother, then what's the use of separating them? What part of the story am I missing here?
use Attribute::Property; package Cool; sub new : New; sub name : Property { $_ = reverse uc; 1 } package main; my $obj = Cool->new; $obj->name = "My right foot"; print $obj->name, "\n";
[Attribute::Property] doesn't actually provide hooks for pre/post "processing"
It provides a single hook for processing and validation: the code block. The value returned by it determines whether the new value is correct (hence the 1 in the example above), but both $_ and $_[1] are aliases for the value that is about to be set, so there's more than enough chance to manipulate the value before it gets assigned.
It should be noted that I also have no idea what C# does. I tried googling, but found only one sort-of relevant document, which has no examples and no explanation that I immediately grokked.
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
In reply to Re: Extending LValuable Subs with Tied Variables
by Juerd
in thread Extending LValuable Subs with Tied Variables
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |