in reply to Re: Reinventing wheels: query string parsing.
in thread Reinventing wheels: query string parsing.
>> It seems like you will inspect each 'd=' part twice...
Yeah, I think your right. To be honest I hadn't really looked at optimizing the code very much, I played around a bit with just setting $i to $j after the inner while loop finishes, but that didn't appear to change the speed one whit ( Probably needs more benchmarks there ) and I was a little uncertain of what exactly I might break by doing that so I took it back out.
>>you just end up with foo => 'three'
Hrm. Thats a case I hadn't thought of. Hm. Now I can't decide exactly what should happen. I'm favoring the idea of turning it into an array of arrays so your case o=foo&d=one&d=two&o=foo&d=three would turn in to $args{o}=[[one,two,three],[three]] only problem is that seems kind of icky, especially the derefencing but I like the idea of being able to call a certain option multiple times.
>>Personally, I would write the final assignment as:
Well, I considered that idea but my mind rebelled against the idea of having to write $arg{foo}->[0] every single time I wanted to access a variable. I'm thinking I'll just leave it how it is at the moment, operating under the assumption that most options will only accept one scalar and if a certain option needs multiple values or can accept them then it will check.