in reply to Re: Hash multiple initialization
in thread Hash multiple initialization
My personal favorite is:my %hash; @hash{qw[ a b c f t u] } = ('toto') x 6; @hash{qw[ b g k p ]} = ('titi') x 4;
Update:Following a request from blazar: the typos made by BroswerUK were that the parentheses were omitted from the lhs of the x operator in both cases, and the final line was terminated with a comma instead of a semi-colon. It was probably the keyboard at fault - I have one just like it.my %hash; my @array = qw[ a b c f t u]; @hash{@array } = ('toto') x @array;
|
|---|