in reply to returning the hash reference
Perl is telling you that it is weird that you are using the variables %TEST_CASE, %PRE_CONFIG and the others at one place, while they are not present anywhere else. So it looks like you have forgotten to declare them, or made a typo (which is what the warning literally says). Warnings are a very good safety net, so unless you are very confident that you understand all the implications, you should NOT disable them. In this case perl is trying to protect you against typos, and other warnings will help you avoid most of your mistakes.
You are using warnings, which is a good thing. You should also use strict which is the extra layer of safety that will make you avoid the most common pitfalls. They are not arbitrary rules, where some people thought it was nicer to do it one way rather than another (that's the contrary of perl philosophy), warnings and strict have been designed to avoid the most common of errors, and the harder to track bugs.
Here you are using symbolic reference, ($ini_sect as a variable name) which is not allowed under strict. The reason for that is that it modifies variables in the background (you don't always know which ones, because the soft doesn't always contain the values you expect), that perl has no control over. Variables declared with my on the other hand are easy for perl to follow, because it knows where they belong (less risk of using a variable in a place where you haven't computed its content), when to get rid of it (better memory management), and exactly how their names are written. But you don't need that, since all the hashes you want are already available has values of your tied hash:
You might want to check that every key exists before returning them.tie %ini_file, 'Config::IniFiles', ( -file => $ConfigFile ); return ($ini_file{TEST_CASE}, $ini_file{PRE_CONFIG}, $ini_file{PROCESS +_RESTART}); # or just return (@ini_file{ "TEST_CASE", "PRE_CONFIG", "PROCESS_RESTA +RT" });
|
|---|