On Sun, Feb 9, 2014 at 10:48 AM, Bill McCormick <wpmccorm...@gmail.com>wrote:

> Trying to map the array list into a hash, but loose the double quotes
> surrounding the key's value.


"lose" the quotes, you mean.  I think the trouble is your thinking the map
will create a list of strings and so the quotes will auto-magically
disappear.  But they don't as they are, in this case, just chars. in the
string.  If you just print the map list:
print (map { split(/=/, $_, 2) } @array, "\n");

you get the 4 strings quotes and all:
foo1"bar1"foo2"bar2"

better shown maybe as:
print (join(", ", map { split(/=/, $_, 2) } @array), "\n");

foo1, "bar1", foo2, "bar2"

You could remove the quotes yourself:
my %hash = (map { s/"//g; split(/=/, $_, 2); } @array);

The map body is a code block, so you can do more than one thing - just need
to have the last line be the one that returns your expected list.  I'm
guessing there's something more to the process here.
-- 

a

Andy Bach,
afb...@gmail.com
608 658-1890 cell
608 261-5738 wk

Reply via email to