hi,
sorry for the off-topic-ness, but I'm being bitten by a
variable-scope problem, and maybe if someone is kind enough can help me
out. Off-list, of course.
I'm writing a module that is called under from embperl and registry
scripts, and I'm finding that the following structure doesn't work:
----- - pseudo code/ sample code --------
use Tie::DBI
my %hash;
sub connect {
# tie %hash to a mysql DB here !
}
sub get_data {
connect();
return $hash{elementA}
}
------------
the connect works, and within &connect, the tied hash works. now
inside &get_data 's scope, the hash is empty. ¿? If I explicitly
'return' a hashref after tying it (and grab it in &get_data), that
hashref works allright, so it's not related to scopes breaking the
workings of Tie::DBI.
I've got this example, from perlmod, that is supposed to work
my $x = 10;
sub bumpx { $x++ }
and it certainly does. Now why doesn't my code work?
By the way: I know it's not good to rely in such poor coding
practices as using module globals, but I've got a small module to
program, 2 such 'global tied hashes', and I'm carefully exporting only
what's needed. So I guess I might get away with it ;)
martin