#! perl -w { package Report; use strict; sub TIESCALAR { my $class = shift; printf "The Start\n"; bless \(my $scalar), $class; } sub FETCH { my $self = shift; printf STDERR "Fetch %s\n", $$self; return $$self; } sub STORE { my $self = shift; my $value = shift; printf STDERR "Store %s\n", $value; $$self = $value; } sub DESTROY { my $self = shift; printf STDERR "The End\n"; } } tie $_ => 'Report'; $\ = "\n"; $_ = 'outside'; foo(qw(one two three)); print; sub foo { local $_ = 'inside'; while(@_) { $_ = shift; print; } }