AidanLee has asked for the wisdom of the Perl Monks concerning the following question:
I've been working on revamping some of my older OOP code to reduce initialization overhead. To this end I've implemented some caching and centralized some of the data into class data. Referring to btrott's solution here I took references to the class data in each instance of the class like so:
$self->{_strings} = \%strings;
Most everything seems to be working pretty well but I'm getting mixed up in how exactly to refer to everything. The 'strings' hash above is structured like so:
$strings{"keystring"}{"contextstring"}{iso}{"langcode"} = "value"
so that i can look up a string by it's keystring, followed by it's contextstring, and then by language. This is, if you can't tell, a hash used as a translation lookup table. the 'keystring' is the string in the original language, and the "value" stored in the deepest level is the translation of that string in lanugage "langcode".
The problem is that elsewhere I'm getting this warning:
Use of uninitialized value in exists at f:/projects/site/bin/lib//I18N/Linguist.pm line 180.
with this bit of code
return $self->{_strings}{$string}{$context}{$self->{_lang}} if( exists $self->{_strings}{$string}{$context}{$self->{_lang}} && $self->{_strings}{$string}{$context}{$self->{_lang}} ne '_MISSING_');
which suggests that I'm referring to the data structure wrong. Can anyone help me figure out the correct syntax for this?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting all turned around with references
by japhy (Canon) on May 30, 2001 at 00:59 UTC | |
by AidanLee (Chaplain) on May 30, 2001 at 01:08 UTC |