[Aberdeen-pm] Quick perl fix needed

znx znxster at gmail.com
Fri Mar 10 08:27:23 PST 2006


Not pretty.. I'm sure there is a better way..

------
$_ = "<blah key=value key2=value2 keyX=valueX keya=\"test\" keyc='wee'/>";

foreach(split(' ([\w="\']+)')) {
	if(/=/) {
		($a, $b) = split(/=/);
		$array{$a} = $b;
	}
}

print $array{'keya'};
----

M
On 10/03/06, Mark McRitchie <mark at arricc.net> wrote:
> Heyas,
>
> I need to convert a string in the form:
> <blah key=value key2=value2 ... keyX=valueX/>
>
> Into an associative array eg:
> arr(key)=value
> arr(key2)=value2
>
> Is there a quick way to do this? Yes its an XML string, but I want to do
> it without having to use any extra packages...
>
> Cheers!
> Mark.
> _______________________________________________
> Aberdeen-pm mailing list
> Aberdeen-pm at pm.org
> http://mail.pm.org/mailman/listinfo/aberdeen-pm
>


More information about the Aberdeen-pm mailing list