in reply to Re: specific array in hash of arrays
in thread specific array in hash of arrays

To satisfy the first condition (exists $hoa{$input}) $input has to be any of arraya, arrayb, arrayc. To satisfy the second condition, $input has to be equal to whatever @{$hoa{arraya}} stringifies to, which is probably 4 (because it's an array in scalar context, giving you the number of items in the array).

Since no string is both equal to array$something and to 4 at once, you'll never get output from that script.

Replies are listed 'Best First'.
Re^3: specific array in hash of arrays
by kwn (Novice) on Oct 09, 2008 at 11:18 UTC
    I see. Would it be possible then to change the second condition in order to make sure that;
    $input has to be equal to arraya or @{$hoa{arraya}}?
    After that I will also need to iterate over each value of arraya... Err another thing I was thinking about was that
    there might be a different way to grab a specific array that exists inside a hash. Lets say I have 50
    arrays inside my hash and I want to do something to each value of a specific array based on <STDIN>. I dont want
    to right out 50 elsif statements... please help!
      I see. Would it be possible then to change the second condition in order to make sure that; $input has to be equal to arraya or @{$hoa{arraya}}?

      Sure, but do you really want that? Are you aware that @{$hoa{arraya}} will again give you 4 when used in a string comparison.

      If you mean things like "has to be equal to any element in @{$hoa{arraya}}" you have to say it that way. We can't guess what you want, so you have to be precise when you say what you want.

      Lets say I have 50 arrays inside my hash and I want to do something to each value of a specific array based on <STDIN>. I dont want to right out 50 elsif statements... please help!

      We might help you, but you have to be more specific. based on <STDIN>" is not specific. What exactly do you want? search an array in which the line from STDIN occurs? Or select an array based on its name, and then do something with that array?