in reply to Re: returning the hash reference
in thread returning the hash reference

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...

Replies are listed 'Best First'.
Re^3: returning the hash reference
by Eily (Monsignor) on Mar 15, 2016 at 09:39 UTC

    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.