... a method of changing several values at once.

I don't see this as a valid way of looking at this behavior. A hash key is always unique, and a hash key always has exactly one scalar value, although this scalar may be a reference to... well, anything, opening up vast possibilities for data structures, code dispatch tables, etc., etc., etc. So the only way to "[change] several values at once" is to replace a (scalar) reference to a bunch of stuff with another (scalar) reference to a different bunch of stuff.

Maybe one useful approximation to "changing several values at once", but with "changing" better understood as "dealing with", is the Perl idiom for implementing named, defaulted, non-positional function arguments. It goes something like:

>perl -wMstrict -le "sub D { my %defaults = qw(foo 999 bar 888 baz 777); ;; my ($hr_args) = @_; my %arguments = (%defaults, %{ $hr_args || {} }); ;; print qq{foo $arguments{foo} bar $arguments{bar} baz $arguments{b +az}}; } ;; D(); ;; D({bar => 2}); ;; D({baz => 1, foo => 3}); " foo 999 bar 888 baz 777 foo 999 bar 2 baz 777 foo 3 bar 888 baz 1

In reply to Re: Hash assignment: Undocumented feature? by AnomalousMonk
in thread Hash assignment: Undocumented feature? by fsavigny

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.