(Oops. Didn't really need to dash off, on second thought.) I slightly suspect your example is more complex than I can deal with. What I meant is simply something like this (and I think it does not matter if the values are simple scalars or references to something complex):
%what_all_workers_have = ( holidays => 30, hours_per_week => 40, office_space => 10, job_title => "Clerk", ); ## turning to John, who is a wheelchair user: %what_john_has = ( %what_all_workers_have, office_space => 20, # needs room to maneuvre hours_per_week => 35, # needs more breaks );
One needn't even worry if %workers_have actually contains the keys office_space and hours_per_week. It will either add or overwrite them, whichever is required. To me, this seems quite elegant and time-saving. In any case, it's less code to type than any other version I could think of.
In reply to Re^2: Hash assignment: UndERDocumented feature?
by fsavigny
in thread Hash assignment: Undocumented feature?
by fsavigny
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |