Code sample: safe to assume @vals and @heads are predefined and contain equal # of values, use strict and use warnings are in place.
if (wantarray) { return @vals; } else { # create hash where keys are from @heads and values are from @vals # then return a reference to that hash, only when not in list context my %vals; @vals{@heads} = @vals; return \%vals; } I was surprised that I could not avoid in the else doing the code in 3 lines (obviously this isn't a huge deal). I was looking for something like: return my @vals{@heads} = @vals; Which didn't work. And this didn't give me the proper hash ref: \@vals{@heads} = @vals; nor did the following execute, it complained about not being able to 'my' the expression: my @vals{@heads} = @vals; I also attempted naming my hash something different (like %hash) but this as I figured didn't help anything. And I tried using assorted (), and {} around varying amounts of stuff in between, in numerous locations to no avail. Why can Perl recognize the construct as a hash but not be able to my it? Or to reference it without the specific \%hash use? Obviously this is not a huge concern and I have moved on, but I was surprised that I couldn't get it to work and thought it an interesting piece of code. Is it possible to my the hash and get a reference to it at once? http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]