my @bits = split( /^(?:([^=]*)=?,?\s+)+$/ , $string ); foreach ( @bits ){ print "$_\n"; }