On Monday 01 March 2004 1:22 pm, Gary Stainburn wrote: > Hi folks, > > I'm trying to move my debug and validate modules to a seperate package. > However, I'm having trouble. I've created a new empty module/package > direct from the perldocs and then put my debug routine in. So far, so > good. > > I then created my program to use it, but I'm having trouble accessing the > %_DEBUG hash in main::. The idea is that when I want to use debug, I > create my hash, use the module, and it accesses my hash. As you can see, > it's not working. I'm assuming that the problems with the syntax I'm using > to access %{$package}::_DEBUG. > [snip]
Typical. As soon as I'd finished writing this, my brain returned. I've now done the following which worked. If anyone has a nicer answer I'd like to see it. sub debug { # return debug info no strict qw{refs}; my $caller=(caller(1))[3]; my $package=''; return 0 unless defined $caller; print "caller=$caller\n"; ($package,$caller)=split('::',$caller); print "package=$package caller=$caller\n"; print "key=$_\n" foreach (keys %{"${package}::_DEBUG"}); return (defined ${"${package}::_DEBUG"}{$caller}) ? ${"${package}::_DEBUG"}{$caller} : 0; }; -- Gary Stainburn This email does not contain private or confidential material as it may be snooped on by interested government parties for unknown and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>