Skip to content

Instantly share code, notes, and snippets.

@tom-lpsd
Created May 22, 2010 15:03
Show Gist options
  • Save tom-lpsd/410130 to your computer and use it in GitHub Desktop.
Save tom-lpsd/410130 to your computer and use it in GitHub Desktop.
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