use strict; package Hoge; open my $file, '>>', 'log.log'; sub TIESCALAR { my $pkg = shift; my $h; bless \$h, $pkg; } sub STORE { my $self = shift; my $val = shift; print $file $val, "\n"; } package main; my $c; tie $c, 'Hoge'; $c = 1; $c = 2; $c = 'aaa';