You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Aaron Johnson <so...@gina.net> on 2002/07/25 15:27:35 UTC
Compatability issue or just bad code
I was digging up some old code and thought I would run it through 2.08b,
I was aware of the foreach with no parentheses change, which this code
had, but this block of code now throws an error as well:
[+ if ($result1->[$count][3] eq "Regular After") {SELECTED} +]
It provides a dynamic "selected" inside of a select form element. Is
this type of behavior no longer support in version 2? Should this type
of coding be avoided regardless of version?
Aaron Johnson
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Compatability issue or just bad code
Posted by Gerald Richter <ri...@ecos.de>.
>
> [+ if ($result1->[$count][3] eq "Regular After") {SELECTED} +]
>
In 2.0 there is only a expression (not a statment allowed) inside of [+ +].
Either use a do around it (but without semikolon at the end)
[+ do { if ($result1->[$count][3] eq "Regular After") {SELECTED} } +]
or rewrite it to
[+ $result1->[$count][3] eq "Regular After"?{SELECTED}:'' +]
which is a littel faster
Gerald
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Compatability issue or just bad code
Posted by Ed Grimm <ed...@asgard.rsc.raytheon.com>.
Disclaimer: I've never used Embperl 2; everything I know about it, I've
gotten from reading this list. This is why I didn't remember this
off-hand... and I could be somewhat off on the particulars.
Ah, you're right. [+ +] blocks now have more strict requirements. You
may get it working again with a semicolon added after it, or you might
need to wrap 'do { };' around it.
First, try just the semicolon.
[+ if ($result1->[$count][3] eq "Regular After") {'SELECTED'}; +]
if that doesn't work,
[+ do { if ($result1->[$count][3] eq "Regular After") {'SELECTED'} }; +]
Ed
On 25 Jul 2002, Aaron Johnson wrote:
> On Thu, 2002-07-25 at 10:21, Ed Grimm wrote:
>> Bad code. SELECTED should be quoted. As you have it here, perl
>> searches for a keyword SELECTED, and if it finds it, it uses whatever it
>> finds. Otherwise, it treats it as a string. You want it to always
>> treat it as a string.
>
> I tried it with quotes and it still returned an error. The code I
> posted is from 1998 so I would not be surprised if it was not valid in
> version 2 or even later versions of 1.3 for that matter.
>
> But if memory serves correct, that code was recommended by Gerald at
> some point because I don't remember being that clever in 1998 :)
>
> Aaron
>
>>
>> Ed
>>
>> On 25 Jul 2002, Aaron Johnson wrote:
>>
>>> I was digging up some old code and thought I would run it through 2.08b,
>>> I was aware of the foreach with no parentheses change, which this code
>>> had, but this block of code now throws an error as well:
>>>
>>> [+ if ($result1->[$count][3] eq "Regular After") {SELECTED} +]
>>>
>>> It provides a dynamic "selected" inside of a select form element. Is
>>> this type of behavior no longer support in version 2? Should this type
>>> of coding be avoided regardless of version?
>>>
>>> Aaron Johnson
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Compatability issue or just bad code
Posted by Aaron Johnson <so...@gina.net>.
On Thu, 2002-07-25 at 10:21, Ed Grimm wrote:
> Bad code. SELECTED should be quoted. As you have it here, perl
> searches for a keyword SELECTED, and if it finds it, it uses whatever it
> finds. Otherwise, it treats it as a string. You want it to always
> treat it as a string.
I tried it with quotes and it still returned an error. The code I
posted is from 1998 so I would not be surprised if it was not valid in
version 2 or even later versions of 1.3 for that matter.
But if memory serves correct, that code was recommended by Gerald at
some point because I don't remember being that clever in 1998 :)
Aaron
>
> Ed
>
> On 25 Jul 2002, Aaron Johnson wrote:
>
> > I was digging up some old code and thought I would run it through 2.08b,
> > I was aware of the foreach with no parentheses change, which this code
> > had, but this block of code now throws an error as well:
> >
> > [+ if ($result1->[$count][3] eq "Regular After") {SELECTED} +]
> >
> > It provides a dynamic "selected" inside of a select form element. Is
> > this type of behavior no longer support in version 2? Should this type
> > of coding be avoided regardless of version?
> >
> > Aaron Johnson
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> > For additional commands, e-mail: embperl-help@perl.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Compatability issue or just bad code
Posted by Ed Grimm <ed...@asgard.rsc.raytheon.com>.
Bad code. SELECTED should be quoted. As you have it here, perl
searches for a keyword SELECTED, and if it finds it, it uses whatever it
finds. Otherwise, it treats it as a string. You want it to always
treat it as a string.
Ed
On 25 Jul 2002, Aaron Johnson wrote:
> I was digging up some old code and thought I would run it through 2.08b,
> I was aware of the foreach with no parentheses change, which this code
> had, but this block of code now throws an error as well:
>
> [+ if ($result1->[$count][3] eq "Regular After") {SELECTED} +]
>
> It provides a dynamic "selected" inside of a select form element. Is
> this type of behavior no longer support in version 2? Should this type
> of coding be avoided regardless of version?
>
> Aaron Johnson
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org