I have studied the Lore of the Perl Monks, and found much to recommend it, but not the answer to my question.
I want to combine two hashes into a third. The following works for my needs, but I would like to know if it is guaranteed to work, or merely coincidental.
%a = (font => 'Arial',
size => 10,
bold => 0);
%b = (size => 12);
%fmt = (%a, %b);
I want the final hash to have
(font=>'Arial',size=>12,bold=>0) so that the values in %b overwrite values in %a where necessary. I'd like to be sure that in future versions of Perl, %a won't suddenly decide to start overwriting %b.
I don't think it should make a difference, but I don't actually plan to create the third hash explicitly; instead, I'll use it in a function call:
$object->write( 'Some Stuff',
$object2->format( %a, (size => 12)) );
My hashes are small and insignificant, yet dear to me. But because they are small I am more concerned with shortness and clarity of the code than with raw efficiency.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.