xref: /openbsd-src/gnu/usr.bin/perl/dist/Attribute-Handlers/demo/demo_cycle.pl (revision b39c515898423c8d899e35282f4b395f7cad3298)
1package Selfish;
2
3sub TIESCALAR {
4	use Data::Dumper 'Dumper';
5	print Dumper [ \@_ ];
6	bless [ @_[1..$#_] ], $_[0];
7}
8
9sub FETCH {
10	use Data::Dumper 'Dumper';
11	Dumper [ @{$_[0]} ];
12}
13
14package main;
15
16use Attribute::Handlers autotieref => { Selfish => Selfish };
17
18my $next : Selfish("me");
19print "$next\n";
20
21my $last : Selfish("you","them","who?");
22print "$last\n";
23
24my $other : Selfish(["you","them","who?"]);
25print "$other\n";
26