In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] (Michael Hooten) writes: >Simpler and easier to read: >@combined = map { ref $_ eq 'ARRAY' ? @$_ : $_ } values %{$hash{family}}; > >Either dereference the array or return the scalar.
Yes, I'm aware of the 'either' in the posting. However, the example cited showed both an array and a scalar being assigned to the key 'family'. My code played it safe and didn't assume they were mutually exclusive. Also, your example only generates the list for one fixed key, instead of going through the whole hash. >In article <[EMAIL PROTECTED]>, > [EMAIL PROTECTED] (Michael Kavanagh) writes: >>Hi there, >> >>I've got a hash that has keys which contain either >>- array references >>- scalar values >> >>for example: >>@values = (12398712984, 19286192879); >>$hashofarrays{'family'}{'arrayref'} = \@values; >>$hashofarrays{'family'}{'scalar'} = 12938712938; >@combined = map { @{$_->{arrayref}||[]}, exists $_->{scalar} ? $_->{scalar} >: () } > values %hashofarrays; -- Peter Scott http://www.perldebugged.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]