Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-25 13:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found