Re: foreach routine
- Posted by duke normandin <dnormandin at bsdrocksperlrolls.com> Dec 22, 2006
- 680 views
duke normandin wrote: > > Chris Bensler wrote: > > > > > Here is some Eu code to do what you want (split() function sold separately) > > Warning: code is not tested, consider it a guideline only > > > > }}} <eucode> > > include get.e -- needed for get_bytes() and value() > > sequence pairs,pair > > sequence name,data -- ('value' is a standard routine name, so I will use > > 'data' instead) > > sequence buffer > > object tmp -- temporary/intermediate variable > > > > tmp = getenv("CONTENT_LENGTH") > > if atom(tmp) then > > -- CONTENT_LENGTH was not found > > else > > tmp = value(tmp) > > if tmp[1] != GET_SUCCESS then > > -- value() failed > > else > > buffer = get_bytes(STDIN,tmp[2]) > > pairs = split(buffer,'&') > > for i = 1 to length(pairs) do > > pair = pairs[i] > > tmp = split(pair,'=') > > name = tmp[1] > > data = tmp[2] > > -- blah > > -- blah > > end for > > end if > > end if > > </eucode> {{{ > > Thanks Chris.... > > Why am I not getting this? > > tmp = getenv("CONTENT_LENGTH") > if atom(tmp) then > > CONTENT_LENGTH > -- > duke I hit the send key too quickly -- my bad! What I was going to say is: CONTENT_LENGTH will either be empty or contain the number of chars/bytes sent. So if atom(tmp) then checks to see if getenv() returned a number, right? If true, we have that many chars/bytes. If 0 CONTENT_LENGTH was empty. Do I need another cup of coffee? or something? It seems that the logic is backwards. TIA... (now hit the send button, duke) -- duke