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:

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" });
You might want to check that every key exists before returning them.


In reply to Re: returning the hash reference by Eily
in thread returning the hash reference by bhushanQA

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.