Hello kind monks. I have a case where a some of my hash keys need adjusting. I thought perhaps:
map s/thesekeys/thosekeys/,keys %h;
.. would be a nice approach but no joy. I guess that "keys %h" is an anonymous array copy of the keys; not the actual keys, because the were unchanged. I never realized that.

Of course I can do this in a loop, and I even managed to do it with a slice followed by a delete. So I'm not asking HOW to accomplish the task - as Larry told me (over and over as I recall) at the OSCONs- there are MANY ways... You know the rest :)

I guess what I'm really asking is, is there a perlVar or function that is the TRUE array of hash key and one of values that,when changed, changes the keys or values?

I guess I see a dilemma with this - since adjusting keys may make the array of keys shorter, and it may not be determinant on how to adjust the values. So this might not even be practical. Although being able to map VALUES does seem appealing and practical. I'm interested in what you expert Monks think?

TY & Blessed Be


In reply to can I change hash keys or values directly by misterperl

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.