in reply to detecting changes in a localised variable
Here I tie $_ to a Complainer package that can warn/carp/croak any time something tries to assign to it.
#!perl -l package Complainer; use Tie::Scalar; use base Tie::StdScalar; use Carp; sub STORE { # Warn out any status info you want here. carp "Tried to assign to \$_"; } sub FETCH { $_ } package main; tie $_, Complainer; $_ = 1; local $_;
Update: Added the fetch method so that reading $_ actually works. not sure why I have to do that, Tie::StdScalar should handle that for me... but this was written in a hurry.
Ted Young
($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: detecting changes in a localised variable
by Tanktalus (Canon) on Feb 18, 2005 at 22:46 UTC | |
by TedYoung (Deacon) on Feb 18, 2005 at 23:15 UTC |