package Testtie;
use Tie::Scalar;
use strict;
sub TIESCALAR {
my $class = shift;
my $var = shift;
bless \$var, $class;
}
sub FETCH {
die;
}
sub STORE {
my $self = shift;
return $$self;
}
1;
####
#!/usr/bin/perl
use Testtie;
tie $f, 'Testtie';
$f = "1\n";
print $f;
####
> ./test_test.pl
Died at Testtie.pm line 17.
####
#!/usr/bin/perl
use Testtie;
tie $f, 'Testtie';
$f = {1 => 2};
print $f->{1};
####
dash2@davehj:~/fun > ./test_test.pl
Died at Testtie.pm line 17.
####
#!/usr/bin/perl
use Testtie;
tie $f, 'Testtie';
$f = sub {print $_};
print $f->(1);
####
> ./test_test.pl
1