"be consistent" | |
PerlMonks |
Referencing globals clobbers databy Joost (Canon) |
on Apr 08, 2002 at 15:14 UTC ( [id://157456]=note: print w/replies, xml ) | Need Help?? |
Your problem is in the last line of the _read() method:
return \%data;this returns a reference to the GLOBAL %FileHash::data that is set by the do $file, so you are using the same hash for all FileHash objects. The quickest way to solve this is to change the offending line with: return {%data};which returns a reference to a COPY of %data, leaving %FileHash::data free to be clobbered by a new do $file anyway, this will still leave your race conditions intact :-) Joost.
In Section
Seekers of Perl Wisdom
|
|