Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CGI.pm parsing odity

0 views
Skip to first unread message

FrankB

unread,
May 16, 2006, 10:01:55 AM5/16/06
to
Hello.

With CGI.pm Oo_style coding,
I use a form with GET method, it parses a textfield with name
attribute:
"participant".
I validate that parameter with Perl's substitute and match handlers in
order to make a file in "/tmp/SOMEDIR/" with names like :
"participant.scorefile".
In that file i regulary use the CGI function save() to save the satus
of
the form and it writes away an annoying trainling "=".

$]cat /tmp/SCORES/JohnDoe.sorefile
gives this :
participant=JohnDoe
=

That is "$query save(FHANDLE);" right after the participant puts his
name, so, the *wanted* dated is in there but I don't know where Perl
gets that empty form parameter, is it even empty form data ? Is it an
assignment ? Why this trailing "=" sign ?

Thanks
--
FrankB


Randal L. Schwartz

unread,
May 16, 2006, 12:50:35 PM5/16/06
to
>>>>> "FrankB" == FrankB <you...@request.yup> writes:

FrankB> In that file i regulary use the CGI function save() to save the satus of
FrankB> the form and it writes away an annoying trainling "=".

FrankB> $]cat /tmp/SCORES/JohnDoe.sorefile
FrankB> gives this :
FrankB> participant=JohnDoe
FrankB> =

FrankB> That is "$query save(FHANDLE);" right after the participant puts his name, so,
FrankB> the *wanted* dated is in there but I don't know where Perl gets that empty
FrankB> form parameter, is it even empty form data ? Is it an assignment ? Why this
FrankB> trailing "=" sign ?

That's "Boulder" format. It's the format of some key/value pair thingy
used in the Human Genome Project.

$ perl -MCGI -e 'CGI->new("a=b&c=d&c=e")->save(\*STDOUT);'
a=b
c=d
c=e
=
$

So yes, that trailing = is a sign that all data has been read, apparently.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<mer...@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

*** Posted via a free Usenet account from http://www.teranews.com ***

xho...@gmail.com

unread,
May 16, 2006, 12:50:13 PM5/16/06
to
you...@request.yup wrote:
> Hello.
>
> With CGI.pm Oo_style coding,
> I use a form with GET method, it parses a textfield with name
> attribute:
> "participant".
> I validate that parameter with Perl's substitute and match handlers in
> order to make a file in "/tmp/SOMEDIR/" with names like :
> "participant.scorefile".
> In that file i regulary use the CGI function save() to save the satus
> of
> the form and it writes away an annoying trainling "=".

If that is the biggest annoyance you face, you are a lucky man indeed.

>
> $]cat /tmp/SCORES/JohnDoe.sorefile
> gives this :
> participant=JohnDoe
> =

Have you bothered to read the documentation for the method you are using?

from perldoc CGI on save():

Both name and value are URL escaped. Multi-valued CGI
parameters are represented as repeated names. A session
record is delimited by a single = symbol. You can write
out multiple records and read them back in with several
calls to new.


> That is "$query save(FHANDLE);" right after the participant puts his
> name, so, the *wanted* dated is in there but I don't know where Perl
> gets that empty form parameter, is it even empty form data ? Is it an
> assignment ? Why this trailing "=" sign ?

So that you can store multiple sessions states in one file, just as the
documentation says.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB

FrankB

unread,
May 18, 2006, 8:10:34 AM5/18/06
to
xho...@gmail.com pretended :

> you...@request.yup wrote:
>> Hello.
>>
>> With CGI.pm Oo_style coding,
>> I use a form with GET method, it parses a textfield with name
>> attribute:
>> "participant".
>> I validate that parameter with Perl's substitute and match handlers in
>> order to make a file in "/tmp/SOMEDIR/" with names like :
>> "participant.scorefile".
>> In that file i regulary use the CGI function save() to save the satus
>> of
>> the form and it writes away an annoying trainling "=".
>
> If that is the biggest annoyance you face, you are a lucky man indeed.

Not really, the biggest annoyance is errors in lines due to my own
stupidity or distraction.


>>
>> $]cat /tmp/SCORES/JohnDoe.sorefile
>> gives this :
>> participant=JohnDoe
>> =
>
> Have you bothered to read the documentation for the method you are using?

Not completely : my lazyness took it over and English is not my primary
language, so I thought i could post here and improve my English while
learning Perl in deeper (grinns: "does this count as an excuse ?")

>> Why this trailing "=" sign ?
>
> So that you can store multiple sessions states in one file, just as the
> documentation says.

I will be back on that later, i am still in the documentation now :
testing out, reading, testing, reading..

Thank you for that answer though, it is makes sense but i don't really
get it.

--
FrankB


FrankB

unread,
May 18, 2006, 8:17:54 AM5/18/06
to
on 16/05/2006, Randal L. Schwartz supposed :

>>>>>> "FrankB" == FrankB <you...@request.yup> writes:
>
> In that file i regulary use the CGI function save() to save the satus
> of the form and it writes away an annoying trainling "=".

> That is "$query save(FHANDLE);" right after the participant puts his
> name, so, the *wanted* dated is in there but I don't know where Perl
> gets that empty form parameter, is it even empty form data ? Is it an
> assignment ? Why this FrankB> trailing "=" sign ?
>
> That's "Boulder" format.

Thanks for that hint :)

> It's the format of some key/value pair thingy
> used in the Human Genome Project.
>
> $ perl -MCGI -e 'CGI->new("a=b&c=d&c=e")->save(\*STDOUT);'
> a=b
> c=d
> c=e
> =
> $

That is it, STDOUT being a FILEHANDLE but yup, that how it cats.

> So yes, that trailing = is a sign that all data has been read, apparently.

Not an assignment, not an empty key=value pair.. just a naked, lonely
equation/equal sign.. aslike "EOF" or "__END__" ?

--
FrankB


0 new messages