http://www.perlmonks.org?node_id=33808

This is a module, but it's so damn tiny, it's a snippet. There's an example of its use in the POD.
package Tie::AssignWrapper; sub TIESCALAR { bless \( $::{"$_[1]::"}{new}->(@_[1..$#_]) ), $_[0] } sub FETCH { ${ $_[0] } } sub STORE { (${ $_[0] })->AWstore($_[1]) } sub DESTROY { (${ $_[0] })->DESTROY } 1; __END__ =head1 NAME Tie::AssignWrapper - catch assignments to objects =head1 SYNOPSIS use Some::Module; use Tie::AssignWrapper; tie $obj, Tie::AssignWrapper => Some::Module => @args; print $obj->value; $obj = "new value"; print $obj->value; =head1 DESCRIPTION This module intercepts the assignment operator, and passes off the assignment to the module beneath it. It calls the C<AWstore> method (so make sure that's what you call it). =head1 AUTHOR Jeff "japhy" Pinyan CPAN ID: PINYAN japhy@pobox.com =cut