my %data = map {split(/=/, $_)} split /&/, $request->content;
This will break when there is a key that does not have a value associated with it. This is a general problem when using map to build a hash. You need to make sure that the code in curly braces returns a list with two elements. How do you solve that problem?
Of course one could simply check for that, but doing so will not fit into that one line. Hereīs what I came up with:
my %data = map {(split(/=/, $_), '')[0,1]} split /&/, $request->content;
Do you have any better ideas.
Andreas
Be sure to read Marcia`s wonderful WebmasterWorld Welcome and Guide to the Basics [webmasterworld.com] post.
Thatīs nice. So Perl will create the missing element in the list on the fly when it is needed. Itīs always so helpful and considerate. Everything just magically comes into existence when it is needed.
Andreas