in reply to Parsing Challenge

All great ideas, thanks! I tried many of them and settled on a hybrid. I had to make a few somewhat ugly tweaks because some of the key names were repeated with different values (intended to be different keys with the same name) funky.. but I just tacked on a increment number to the key name. Hey whatever works right?
Here is the code
my $data="fruit=pear meat=chicken legs fruit=orange slices cheese=mont +erey jack meal=lunch meat=ribs bread= "; my %foo; while ($data =~ m/(\S+)=(\S*($|([^=]+\s+)*))/g) { my ($tmpkey,$tmpval); my $count=1; $tmpkey=$1; $tmpval=$2; while (defined $foo{$tmpkey}){ $count++; $tmpkey=~s/\_\d+$//; $tmpkey.="_$count"; } $foo{$tmpkey}=$tmpval; } for (sort (keys %foo)){ if ($_!~/_\d+/){ my $rm=$_; $_.="_1"; $foo{$_}=$foo{$rm}; delete $foo{$rm}; } chomp ($_,$foo{$_}); print "$_->$foo{$_}\n"; }