# match the required part /^\s*(\w+)\s*=\s*(\w+)/gc; ($keyword, $value) = ($1,$2); # match the optional part @optional = /\G\s*,\s*(\w+)/g;