http://www.perlmonks.org?node_id=1048744


in reply to How to create a hash from string

Or this:

use warnings; use strict; use Data::Dumper; my %h = map $_ => split/:|,/ => 'x:q,y:u,z:n'; { local $Data::Dumper::Sortkeys = 1; ## Update print Dumper \%h; }
UPDATE:
In the solution, map is not even needed. Without it, you still have your solution.
choroba caught that!

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me