in reply to creating hashes

If the key - values lines are set up as follows key\tvalue1 value2 value3 (in other words a tab separates the key from the values and the values are separated by spaces, you could split on generic whitespace: my($key, @values) = split(/\s/,$_); and then store a reference to the @values array in your hash: $$hash{$key} = \@values;

One other comment: you might wish to chomp the result from your <TABLE> to get rid of the EOL character(s).

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Replies are listed 'Best First'.
Re^2: creating hashes
by CountZero (Bishop) on Jan 09, 2008 at 11:05 UTC
    My suggestion indeed is to "use a hash of anon arrays...where 'bob', 'sally', 'sue' are entries 0, 1, 2 of teh anon array" and of course the anon array is the value linked to each key in your hash.

    You therefore would need to de-reference the anon-array reference to get at the names. How you put these in your combo box is a bit beyond me. Personally, I would use two combo-boxes, one with your hash keys which, once you pick one entry, dynamically loads the names related to that key and puts them in the second combo-box. A clear case for an AJAX-empowered web-page if you ask me ;-)

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re^2: creating hashes
by philc (Acolyte) on Jan 09, 2008 at 07:58 UTC

    Intriguing.....one concern, how would this work with multpile key/value pairs, say 20 pairs with 20 values each..(not extreme by any means). For the combo box I will need to access the keys and values discretely. Having an array ref, as I understand it and I could be wrong, means the entire value set is a single array entry at array[0].

    In your proposal you get Name 'bob sally sue',

    It got me thinking, and perhaps this is just restating your idea (and i apologize if it is) that I should either be using an array outright instead of a hash or use a hash of anon arrays...where 'bob', 'sally', 'sue' are entries 0, 1, 2 of teh anon array. Hmmmm....

    Thanks for the chomp tip...head slap...:)

Re^2: creating hashes
by philc (Acolyte) on Jan 10, 2008 at 05:35 UTC

    Graff's original suggestion works great...sorry, head slap, just too rusty here to see it and thought it had to be more complicated. The following code populates the combobox

    sub PopulateComboBox { my $hash = shift; foreach my $key(keys (%$hash)){ $MainWindow->FilterList->Add($key); foreach (@{$$hash{$key}}) { $MainWindow->FilterList->Add($_); } } $MainWindow->FilterList->SetCurSel(0); }

    many thanks