Is there no need of defining perl hash variables at the beginning of the code.
For example, I found in a script a variable "trans" that was not defined as my %trans
or %trans
anywhere in the code. But the following codes seemed to be working.
$trans{$lang_code} = set_elements($files_to_process{$lang_code},@tags_to_extract);
and
$test = $trans{lc $Preferred_Language}->{'t_14'};
Does Perl interpret "trans" as a hash variable after checking the syntax and proceed?. Is that what happens
Without
use strict
, global variables are created automatically when you use them. Handy for one line scripts, but generally frowned upon. Also, keys in hashes are automatically created as well. You'll see fewer people complaining about code like$trans{'key1'}{'subkey'}{'detailkey'}{'deepkey'} ++
which creates key1, subkey, detailkey and deepkey in each of those hashes if they don't already exist.