in reply to "Hash Matrix" Design Question

If this data structure is big, you might put it into a config file and use a modul from the CPAN config hierarchy to read that config file. If you don't like a separate file, put it into the __DATA__ section.

Naturally you also need to check afterwards if every mandatory entry in the matrix is filled in, but that is a good idea anyway

The main advantage is that the configuration data is separate from the code.

Replies are listed 'Best First'.
Re^2: "Hash Matrix" Design Question
by rovf (Priest) on Sep 24, 2008 at 13:28 UTC
    If this data structure is big, you might put it into a config file

    This is not possible, because it needs to be computed at run time...

    -- 
    Ronald Fischer <ynnor@mm.st>

      Then your conf idea sounds good.

      A different idea might be to have three subs like this:

      my @alloptions=(); my @allOS=(); sub add_OS { # add an operation system to the configuration matrix my $os= shift; push @allOS, $os; foreach my $opt (@alloptions) { calculate_parameter($os,$opt); } } sub add_option { # add a configuration option to the configuration matrix my $option= shift; push @alloptions, $option; foreach my $os (@allOS) { calculate_parameter($os,$option); } } sub calculate_parameter { # calculate the option parameter in a specific OS my ($os, $option)= @_; ...

      Creating and filling the matrix is automatically done by calling add_OS and add_option for every os and option.