use strict; use warnings; { package Debug::Tie::StdScalar; use Tie::Scalar; use Carp; sub AUTOLOAD { our $AUTOLOAD =~ s/Debug:://; carp join " >|< ", "calling $AUTOLOAD", @_[1..$#_], ""; goto &$AUTOLOAD; } } # example use my $x; tie $x, 'Debug::Tie::StdScalar', 4; print $x; $x = 3; $x .= "abc"; ++$x;