in reply to clean code
Pleonastic quoting and parentheses decrease the ease with which I can read code. But a map is well suited for this task:
my %data=map +(split /=/)[0,1], split /;/, $memory_data;
The [0,1] thing is there just in case split /=/ would return more than two entries, which may be possible. Depending on the reliability of your input you may either leave it out altogether or on the contrary add more strict checks.
Also, this assumes you want to fill %data all at once. If you're just adding (and possibly replacing) key-value pairs to it instead, then just:
%data=(%data, map +(split /=/)[0,1], split /;/, $memory_data);
|
|---|