Somni is correct about using a reference to pass the tied hash around. In the code you have, you'd return \%hash inside hash_init. Outside, you'd say my $hash_ref = hash_init() and then $hash_ref->{$id} to access some part of it.
That aside, I notice you flock after the hash has been tied. I think it would be better to get a lock on something before the hash is tied. You may want to use a separate lock file for that purpose. I don't know for a fact that what you're doing now leaves room for a problem, but it looks suspicious to me.
In reply to Re: Proper way of passing around tie'd variable
by kyle
in thread Proper way of passing around tie'd variable
by graffitici
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |