$string = "column08=Submit & column10=Delivered & column09=Something" my @matches = grep defined, split / ([|&]) /, $string; $i = 1; foreach my $one (@matches) { if (($one =~ tr/=//) == 1) { my ($key,$value)=(split /=/,$one); %hash = (); $hash{'term'}{$key} = $value; push (@return_array,%hash); } else { push (@symbol_array,$one); } } print Dumper \%hash; print Dumper \@return_array;