[Aberdeen-pm] Quick perl fix needed

Mark McRitchie mark at arricc.net
Fri Mar 10 08:39:34 PST 2006


Cool, that looks a lot better than the way I ended up doing it :)

Glad you're looking for quoted values as I forgot to put that in my
original msg :D

Cheers!
Mark.

On Fri, 10 Mar 2006, znx wrote:
> 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
> >
> _______________________________________________
> 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