Next | Tricks of the Wizards | 74 |
If you assign to a tied variable and you don't have a STORE method defined, you'll get a fatal error.
The standard Tie::StdScalar, Tie::StdArray, and Tie::StdHash classes provide reasonable defaults.
But for simple behavior, an easy thing to do is
sub unimplemented { }
or
# Load `Carp' when needed sub forbidden { require Carp; Carp::croak("Operation not permitted on tied hash"); }
for $name (qw(STORE DELETE CLEAR FIRSTKEY NEXTKEY)) { *{$name} = \&forbidden; }
There's that magic glob again.
Next | Copyright © 2003 M. J. Dominus |