@tags = grep defined, $xml =~ /|(<(?>[^"'>]+|'[^']*'|"[^"]*")*>)/sg; #### @tokens = split /|(<(?>[^"'>]+|'[^']*'|"[^"]*")*>)/s, $xml;