Click here to get back home

CGI.pm parsing odity

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
CGI.pm parsing odity FrankB 05-16-2006
Posted by FrankB on May 16, 2006, 10:01 am
Please log in for more thread options


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



Posted by xhoster on May 16, 2006, 12:50 pm
Please log in for more thread options


you.did@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

Posted by FrankB on May 18, 2006, 8:10 am
Please log in for more thread options


xhoster@gmail.com pretended :
> you.did@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



Posted by Randal L. Schwartz on May 16, 2006, 12:50 pm
Please log in for more thread options



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
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 ***

Posted by FrankB on May 18, 2006, 8:17 am
Please log in for more thread options


on 16/05/2006, Randal L. Schwartz supposed :
>
> 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



Similar ThreadsPosted
XML::DOM parsing pb March 9, 2006, 1:27 pm
XML Parsing too slow November 19, 2005, 7:29 am
HTML parsing March 21, 2005, 3:24 pm
Image data parsing October 27, 2004, 3:36 pm
Parsing OpenOffice Spreadsheets April 25, 2005, 7:23 pm
can't find xml-parsing module... May 27, 2006, 5:30 am
Lemur parsing module June 20, 2006, 10:44 pm
XML::Atom::Feed - parsing at all? January 20, 2008, 5:04 pm
Parsing AVI header information June 8, 2008, 11:08 pm
Parsing Doctype Entitites using XML::XPath November 5, 2004, 10:13 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap