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; #### use strict; use warnings; { package Debug::Tie::StdScalar; use Tie::Scalar; use Carp; sub TIESCALAR { my $obj = &Tie::StdScalar::TIESCALAR(@_); carp join(" >|< ", "calling Tie::StdScalar::TIESCALAR", @_[1..$#_]), "\n=> ", 0+$obj; $obj; } sub AUTOLOAD { our $AUTOLOAD =~ s/Debug:://; carp join " >|< ", "calling $AUTOLOAD", 0+$_[0], @_[1..$#_], ""; goto &$AUTOLOAD; } }