| Next | Tricks of the Wizards | 64 |
package Eval;
sub import {
my ($package, $name) = @_;
$name = 'Eval' unless defined $name;
my %magical_hash;
tie %magical_hash => Eval;
my $caller = caller;
*{$caller . '::' . $name} = \%magical_hash;
}
There's that magic glob again.
sub TIEHASH {
my $self = \'dummy';
bless $self => 'Eval';
}
use Eval now calls Eval::import
import creates and ties a hash, which it exports back to the caller
When the caller examines the data in the hash, Eval::FETCH is called
| Next | ![]() |
Copyright © 2003 M. J. Dominus |