in reply to returning the hash reference

You can easely escape this error, if it is what you want and you understand it, using no warnings qw(once);

See warnings for more details. Or you can declare such hashes before setting their values from INI file.

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: returning the hash reference
by bhushanQA (Sexton) on Mar 15, 2016 at 09:35 UTC
    If I use  no warning;, no use actually... It only removes the compilation errors but while de-referencing the hash reference it will only does for 1st one...

      You should never remove a warning if you don't understand it perfectly, even if the code still seems to be working properly, it might be doing some extra things that you don't see, or skipping some steps.

      Here the problem is that return can happen only once in a function, has it exits it and returns (obviously) the result straightaway. So your for loop is only called for one key of the tied hash, and all the other iterations never have a chance to be ran.

        yes i was only saying that if anything external introduces new names in the main namespace but such names appear only once in the main source file, and if you check consistence of them, is the right case to escape that particular warning using no warnings qw(once); possibly with a scope as little as you can.

        Regarding the return misuse (that i missed completely) you are obviously right!

        L*

        There are no rules, there are no thumbs..
        Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.