[Melbourne-pm] How to create data structures with 'default values'

Shlomi Fish shlomif at iglu.org.il
Mon Nov 17 01:40:34 PST 2008


On Monday 17 November 2008, Alec Clews wrote:
> G'Day Perl Bunnies,
>
> I have created a hash structure with a set of environment specific keys
> and values.
>
> * There is a different hash for each of the environments.
>
> * Many of the values are the same (default) across all the
> environments.
>
> What is the easy way of setting up the defaults once and then have each
> environment overwrite the default values with specific settings?
>
> Currently I have a hash of defaults. However it's a pain to define each
> specific value or assign the default value for every single key in every
> single environment.
>

Can you do something like:

{{{
my %total_hash = (%default_hash, %unique_hash);
}}}

Note that it won't merge keys - just over-write them.

Regards,

	Shlomi Fish

> Thanks.
>
>
> -
> Alec Clews <alec.clews at voga.com.au>               Principal Consultant
> Jabber: alecclews at jabber.org.au               Voga Consulting Services
> skype: alecclews      Voice: +61(425)770-886   http://www.voga.com.au/
> blog:http://alecthegeek.wordpress.com/            Melbourne, Australia



-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Funny Anti-Terrorism Story - http://xrl.us/bjn7t

Shlomi, so what are you working on? Working on a new wiki about unit testing 
fortunes in freecell? -- Ran Eilam


More information about the Melbourne-pm mailing list