CGI.pm and scrolling list box code error

--------------020805030008080906060702
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Hello, World!

I'm an amateur programmer trying to convert some of my old BASIC
programs to run in a browser so people don't have to download and
install software. I'm having a problem with my current project because
CGI.pm is generating some funny code when I try to evoke a scrolling
list box.

Here's the relevant evocation:

print scrolling_list(-name =3D> 'choose',-values=3D> [at] terms,-size=3D>2=
54);

The HTML code output should look something like this:

<SELECT NAME=3D"choose" SIZE=3D"254">

<OPTION> abreaction
<OPTION> abstract thinking
<OPTION> acalculia
.
.
.
<OPTION> word salad
<OPTION> xenophobia
<OPTION> zoophobia
</SELECT>

What I'm actually getting follows:

<select name=3D"choose" size=3D"254" delusion
=3D"delusion of control " declarative memory
=3D"decreased libido " screen memory
=3D"seizure " olfactory hallucination
=3D"overvalued idea " folie =E0 deux =

=3D"formication " delusion of grandeur
=3D"dementia " coma
=3D"compulsion " catatonic rigidity
=3D"catatonic stupor " preoccupation
=3D"pressure of speech " apathy
=3D"appropriate affect " dissociation
=3D"dissociative amnesia " free-floating anxiety
=3D"fugue " tremor
=3D"trichotillomania " nihilism
=3D"obsession " loose associations
=3D"macropsia " dysphoria
=3D"dysprosody " ideas of reference
=3D"illusion " clouded consciousness
=3D"cluttering " sundowning
=3D"suppression " somnolence
=3D"stereotypy " distractibility
=3D"diurnal variation of mood " shame
=3D"sleepwalking " negativism
=3D"neologism " perseveration
=3D"phantom limb " psychogenic mutism
=3D"psychomotor retardation " insight
=3D"insomnia " automatic obedience
=3D"automatism " echolalia
=3D"echopraxia " dystonia
=3D"d=E9j=E0 entendu " somatic delusion =

=3D"somatization " agraphia
=3D"akathisia " dysarthria
=3D"dyscalculia " thought insertion
=3D"thought withdrawal " derealization
=3D"dereism " sublimation
=3D"suicidality " cataplexy
=3D"catatonic excitement " immediate recall
=3D"imperative hallucination " remote memory
=3D"repression " humor
=3D"hyperactivity " tics
=3D"trailing " psychosis
=3D"rationalization " passive-aggression
=3D"pathological jealousy " motor aphasia
=3D"needle phobia " tactile hallucination
=3D"tangentiality " panic
=3D"paranoid delusion " labile affect
=3D"labile mood " dysdiadochokinesia
=3D"dysgraphia " jamais v=E9=E7u =

=3D"judgment " recent memory
=3D"regression " performance anxiety
=3D"persecutory delusion " mimicry
=3D"moderate mental retardation " polyphagia
=3D"posturing " social intelligence
=3D"social phobia " severe mental retardation
=3D"sexualization " restricted affect
=3D"retrograde amnesia " irritable mood
=3D"isolation " retrospective falsification
=3D"schizoid fantasy " magical thinking
=3D"mannerism " jamais entendu
=3D"jamais vu " alexia
=3D"alexithymia " grief
=3D"guilt " thought broadcasting
=3D"thought disorder " inappropriate affect
=3D"inhibition " bradykinesia
=3D"catalepsy " mental retardation
=3D"mental rituals " profound mental retardation
=3D"projection " intelligence
=3D"intelligence quotient " tension
=3D"thought blocking " anosognosia
=3D"anterograde amnesia " verbigeration
=3D"visual hallucination " perception
=3D"performance IQ " denial
=3D"depersonalization " mood-congruent
=3D"mood-incongruent " intellectual insight
=3D"intellectualization " gustatory hallucination
=3D"hallucination " primary process
=3D"procedural memory " acrophobia
=3D"acting out " disorientation
=3D"displacement " introjection
=3D"intuition " erythrophobia
=3D"euphoria " ecstasy
=3D"egomania " stupor
=3D"stuttering " altruism
=3D"ambivalence " aura
=3D"autistic thinking " xenophobia
=3D"zoophobia " abstract thinking
=3D"acalculia " confusion
=3D"controlling " agnosia
=3D"agoraphobia " blocking
=3D"blunted affect " externalization
=3D"fear " anticipation
=3D"anxiety " concrete thinking
=3D"confabulation " poverty of content
=3D"poverty of speech " micropsia
=3D"mild mental retardation " twirling
=3D"verbal IQ " astasia-abasia
=3D"astereognosis " pseudodementia
=3D"pseudologia " trance
=3D"transient global amnesia " coprolalia
=3D"coprophagia " ataxia
=3D"auditory hallucination " eidetic memory
=3D"elation " hypervigilance
=3D"hypnagogic hallucination " dissociative identity disorder
=3D"distortion " global aphasia
=3D"glossolalia " euthymia
=3D"expansive mood " selective inattention
=3D"sensory aphasia " aggression
=3D"agitation " chorea
=3D"circumstantiality " hyperphagia
=3D"hypersomnia " hypnopompic hallucination
=3D"hypochondriasis " synesthesia
=3D"systematized delusion " anomia
=3D"anorexia " waxy flexibility
=3D"word salad " reaction formation
=3D"reality testing " anergia
=3D"anhedonia " flat affect
=3D"flight of ideas " melancholia
=3D"mental age " d=E9j=E0 vu =

=3D"d=E9j=E0 v=E9=E7u " apraxia =

=3D"asceticism " depression
=3D"derailment " phobia
=3D"pica " bizarre delusion
=3D"blackout " delayed recall
=3D"delirium " dyskinesia
=3D"dyslexia " elevated mood
=3D"erotomania " clanging
=3D"claustrophobia ">
<option value=3D"abreaction ">abreaction </optio=
n>
</select>

This produces a list box with only one term visible. Am I doing
something wrong with CGI.pm or is there a glitch in it?

Thanks!

John M Rathbun MD
Asheville, NC



--------------020805030008080906060702--
John M Rathbun MD [ Di, 31 Mai 2011 02:48 ] [ ID #2060294 ]

Re: CGI.pm and scrolling list box code error

>>>>> "JMRM" == John M Rathbun MD <jmrathbun [at] bellsouth.net> writes:

JMRM> I'm an amateur programmer trying to convert some of my old BASIC
JMRM> programs to run in a browser so people don't have to download and
JMRM> install software. I'm having a problem with my current project because
JMRM> CGI.pm is generating some funny code when I try to evoke a scrolling
JMRM> list box.

JMRM> Here's the relevant evocation:

JMRM> print scrolling_list(-name => 'choose',-values=> [at] terms,-size=>254);

when i run this one liner it looks ok:

perl -MCGI=scrolling_list -le 'print scrolling_list( -name => 'z',-values=>[1,2,3],-size=>3)'
<select name="z" size="3">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>


try to show an example with shorter data that has the same error. i also
ran the same one liner with 1..254 for the data and it seems to work as
well. i would then suspect you have some other problem in your code that
we can see. try to created a complete but short program that shows this
problem. in doing so you may even find the bug. i doubt it is in CGI.pm
as that module has been around forever and is considered very solid.

also you can easily generate that html by yourself with a simple loop or
a templater. if you can get cgi.pm to work, do that yourself.

also note that the html i saw generated is somewhat different than what
you want. it has both values and labels (which are the same here)
whereas yours only shows the labels and isn't proper html anymore.

uri

--
Uri Guttman ------ uri [at] stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Uri Guttman [ Di, 31 Mai 2011 05:21 ] [ ID #2060296 ]

Re: CGI.pm and scrolling list box code error

On Mon, May 30, 2011 at 08:48:44PM -0400, John M Rathbun MD wrote:
> print scrolling_list(-name => 'choose',-values=> [at] terms,-size=>254);

scrolling_list wants a reference for the value list:
print scrolling_list(-name => 'choose',-values=>\ [at] terms,-size=>254);

This should do what you want, when you use ' [at] terms' the array gets
expanded to the list of items in the array, the backslash causes a
reference to the array to be passed instead. The relevant
documentation is perlref
<http://perldoc.perl.org/perlref.html#Making-References>.


--
Michael
michael [at] thegrebs.com
M: +1-562-MIKEGRB

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Michael Greb [ Di, 31 Mai 2011 05:55 ] [ ID #2060298 ]

Re: CGI.pm and scrolling list box code error

Hi John,

On Tuesday 31 May 2011 03:48:44 John M Rathbun MD wrote:
> Hello, World!
>
> I'm an amateur programmer trying to convert some of my old BASIC
> programs to run in a browser so people don't have to download and
> install software. I'm having a problem with my current project because
> CGI.pm is generating some funny code when I try to evoke a scrolling
> list box.
>
> Here's the relevant evocation:
>
> print scrolling_list(-name => 'choose',-values=> [at] terms,-size=>254);
>

The problem here is that -values accepts an array reference, not an array, so
you need either:

print scrolling_list(-name => 'choose', -values => \ [at] terms, -size => 254);

Or:

print scrolling_list(-name => 'choose', -values => [ [at] terms], -size => 254);

See the resources in: http://perl-begin.org/topics/references/ .

> The HTML code output should look something like this:
>
> <SELECT NAME="choose" SIZE="254">
>
> <OPTION> abreaction
> <OPTION> abstract thinking
> <OPTION> acalculia
> .
> .
> .
> <OPTION> word salad
> <OPTION> xenophobia
> <OPTION> zoophobia
> </SELECT>
>

This is non-standards-compliant HTML code.

> What I'm actually getting follows:
[SNIP]
> This produces a list box with only one term visible. Am I doing
> something wrong with CGI.pm or is there a glitch in it?
>

Well, I would strongly suggest against using CGI.pm's HTML generation
routines. Instead you should use either the Template Toolkit (
http://template-toolkit.org/ ) or alternatively
http://search.cpan.org/dist/HTML-FormFu/ or something like that.

Regards,

Shlomi Fish

--
------------------------------------------------------------ -----
Shlomi Fish http://www.shlomifish.org/
Understand what Open Source is - http://shlom.in/oss-fs

NASA Uses COBOL.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Shlomi Fish [ Di, 31 Mai 2011 08:43 ] [ ID #2060305 ]

Re: CGI.pm and scrolling list box code error

On 2011-05-31 02:48, John M Rathbun MD wrote:

> I'm an [...] trying to convert some of my old BASIC
> programs to run in a browser

Use JavaScript?

--
Ruud

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
rvtol+usenet [ Di, 31 Mai 2011 10:15 ] [ ID #2060350 ]
Perl » gmane.comp.lang.perl.beginners » CGI.pm and scrolling list box code error

Vorheriges Thema: problem with dbi oracle blob
Nächstes Thema: Timer in perl