I'm trying to copy an array to a hash, such that each element of the array is a key, followed by an empty value.
my %questions = map { @u_list => $_ } @u_list;
This only prints out
=>
I see on perldoc this idiom:
%hash = map { get_a_key_for($_) => $_ } @array;
But I cannot figure out how to set the keys. I want the keys to be each element in the array.
Super confusing but functional answer:
@questions{@u_list}=();
This is using the hash slice syntax to specify a set of hash keys..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With