in reply to Using 'keys' on a list
>Also, is there a way of creating a hash for consumption by 'keys' in the above situation which doesn't involve creating a hash reference from a list and then immediately dereferencing?
this is because hash hope first argument is a hash or array, so if offer a list the first argument is first element of list.
so keys just can't work on 'a' (in your example)...
if want keys work on return values of f(), the list still need stored into hash or array.
but you hope finish in one line but don't want %{{}}my %hash = f(); my @keys = keys %hash;
hope this can help.my @keys = keys %{f()}; #or in postfix dereferencing my @keys = keys f()->%*;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using 'keys' on a list
by Anonymous Monk on Jun 30, 2021 at 12:02 UTC | |
by LanX (Saint) on Jun 30, 2021 at 12:32 UTC | |
by Anonymous Monk on Jun 30, 2021 at 14:38 UTC | |
by The Perlman (Scribe) on Jun 30, 2021 at 15:29 UTC | |
by Anonymous Monk on Jun 30, 2021 at 15:35 UTC | |
| |
by The Perlman (Scribe) on Jun 30, 2021 at 13:21 UTC | |
by Anonymous Monk on Jun 30, 2021 at 14:36 UTC | |
by The Perlman (Scribe) on Jul 01, 2021 at 10:17 UTC |