I have an array as follows:
@array = ('a:b','c:d','e:f:g','h:j');
How can I convert this into the following using grep and map?
%hash={a=>1,b=>1,c=>1,d=>1,e=>1,f=>1,h=>1,j=>1};
I've tried:
@arr;
foreach(@array){
@a = split ':' , $_;
push @arr,@a;
}
%hash = map {$_=>1} @arr;
but i am getting all the values i should get first two values of an individual array
galso?