in reply to strict "vars" mode for hash key literals?

See Hash::Util for the concept of 'restricted hashes'.

That said, I don't know of anyone who has used perl for more than a few weeks that feels the need to use them; nor in the 12 or 13 years since 5.8, have I encountered any code in the wild that uses them.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: strict "vars" mode for hash key literals?

Replies are listed 'Best First'.
Re^2: strict "vars" mode for hash key literals?
by Corion (Patriarch) on Oct 18, 2016 at 16:21 UTC

    I use them to great effect with results fetched from an SQL query. There, locked hashes have made it very obvious when my code tries to access elements which have been renamed in the SQL query, which has reduced the time to debug these things.

    But when I'm at liberty to name the hash entries myself, I don't feel the need for restricted hashes.

Re^2: strict "vars" mode for hash key literals?
by davido (Cardinal) on Oct 18, 2016 at 16:14 UTC

    While I agree that I've never encountered restricted hashes in real code, and have never felt like I should reach for them, I also cannot say that I have never been bitten by problems that they could have prevented. Unfortunately, unlike use strict, they are a feeble solution that is inelegant to wield.


    Dave

      I certainly wasn't counsellings against their use; just noting that I am unable have no basis upon which to recommend for them.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.

        I think we're in agreement. :)


        Dave