# parses text like: # name = japhy age = "22" lang = 'Perl' # into a hash... but doesn't capture the quotes! my %data = $text =~ m{ ([^=\s]+) \s* = \s* (?: (?3= ['"] ) (.*? ) \3 | ( \S+ ) ) }xg; #### while ( ) { my %data = $_ =~ m{ ([^=\s]+) \s* = \s* ["']?( (?<=')[^']* | (?<=")[^"]* | \S+ )["']? }xg;