in reply to Regex to match "this=that" multiple times

use strict; use warnings; use Data::Dumper; while (<DATA>) { my @pairs; while (/(\w+="\w+")/g) {push @pairs, $1} print Dumper(\@pairs); } __DATA__ text one="1" two="2" three="3" x="y"

prints:

$VAR1 = [ 'one="1"', 'two="2"', 'three="3"', 'x="y"' ];

Update: The key is to use the regex global modifier //g and a while loop. See also perlrequick.