Created
May 22, 2010 15:03
-
-
Save tom-lpsd/410130 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Foo; | |
use 5.010; | |
use strict; | |
use warnings; | |
sub TIESCALAR { | |
my $class = shift; | |
bless \(my $init = "initial value"), $class; | |
} | |
sub FETCH { | |
my $self = shift; | |
return $$self; | |
} | |
sub STORE { | |
my $self = shift; | |
$$self = shift; | |
} | |
sub foo { | |
say "foo"; | |
} | |
package main; | |
use 5.010; | |
use strict; | |
use warnings; | |
my $f = tie my $foo, 'Foo'; | |
say $foo; | |
$f->foo; | |
(tied $foo)->foo; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment