1package Very::Selfish; 2 3sub TIESCALAR { 4 use Data::Dumper 'Dumper'; 5 bless { value => $_[2] }, $_[0]; 6} 7 8sub FETCH { 9 $_[0]{value}++; 10} 11 12package main; 13 14use Attribute::Handlers::Prospective 15 autotieref => { UNIVERSAL::Selfish => Very::Selfish }; 16 17package Elsewhere; 18 19while (<>) { 20 chomp; 21 my $next : Selfish($_); 22 23 print "$next\n"; 24 print "$next\n"; 25 print "$next\n"; 26} 27