You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Andre Landwehr <an...@gmx.net> on 2000/05/15 19:25:46 UTC

weird problem with arrays

hi,
I'm not sure if Embperl has anything to do with this or if it is
Perl here (or just my own dumbness again as for that...):
I pass several values to a page, called 
starter1, starter2, starter3
main_course1, main_course2, main_course3
dessert1, dessert2, dessert3

For easier processing later in the page the first thing I do is
to throw them into arrays:
my @starter;
$starter[1] = $fdat{starter1};
$starter[2] = $fdat{starter2};
...

Then I call a sub, which is below on the same page:
updatedatabase();

And now I undef my arrays:
undef @starter; 

In the sub I want to put $starter[1] et al. into a database, but
every tenth or so call of the page they are undefined! If I do
not write the undef's earlier, for the same amount of calls to the
page suddenly the arrays contain old values, entered several
minutes ago. 
I cannot see how this is possible since @starter is global and
should still hold the value passed to it earlier from %fdat. 
%fdat contains the correct value.

The Embperl version is 1.3b2, modperl 1.21, Apache 1.3.9
The error occurs on Linux (Debian), Linux (Mandrake with
self build Apache etc.) and on HP-UX

Any suggestions?

Andre


Re: weird problem with arrays

Posted by "Erich L. Markert" <em...@pace.edu>.
Not knowing all of your code...  The reason I suggested the indexing was
because their might be some dependency upon $starter[0].

One other thing to look at is the possibility of "my starter;" messing
things up.

I found that "my" can sometimes cause problems with Embperl.

Andre Landwehr wrote:
> 
> On Mon, May 15, 2000 at 01:42:38PM -0400, Erich L. Markert wrote:
> > Hmmm... Wouldn't have anything to do with the fact that you're array
> > assignment is to index 1 and not 0?
> >
> > Try:
> >
> > my @starter = ();
> > $starter[0] = $fdat{'starter1'};
> > ...
> >
> 
> If I do never use starter[0] it should not matter if I start with
> starter[1], right?
> I think I found a workaround by putting the array assignment
> starter[1] = $fdat{starter1} also into the sub. The last twenty
> calls I did were successful, but that doesn't explain the
> originally described behaviour.
> 
> Andre
> 
>   ------------------------------------------------------------------------
>    Part 1.2Type: application/pgp-signature

--
__________________________________________________________
Mr. Erich L. Markert                     emarkert@pace.edu
Computer Learning Center		 TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
                -- Henry Spencer

Re: weird problem with arrays

Posted by "Erich L. Markert" <em...@pace.edu>.
Hmmm... Wouldn't have anything to do with the fact that you're array
assignment is to index 1 and not 0?

Try:

my @starter = ();
$starter[0] = $fdat{'starter1'};
...



Andre Landwehr wrote:
> 
> hi,
> I'm not sure if Embperl has anything to do with this or if it is
> Perl here (or just my own dumbness again as for that...):
> I pass several values to a page, called
> starter1, starter2, starter3
> main_course1, main_course2, main_course3
> dessert1, dessert2, dessert3
> 
> For easier processing later in the page the first thing I do is
> to throw them into arrays:
> my @starter;
> $starter[1] = $fdat{starter1};
> $starter[2] = $fdat{starter2};
> ...
> 
> Then I call a sub, which is below on the same page:
> updatedatabase();
> 
> And now I undef my arrays:
> undef @starter;
> 
> In the sub I want to put $starter[1] et al. into a database, but
> every tenth or so call of the page they are undefined! If I do
> not write the undef's earlier, for the same amount of calls to the
> page suddenly the arrays contain old values, entered several
> minutes ago.
> I cannot see how this is possible since @starter is global and
> should still hold the value passed to it earlier from %fdat.
> %fdat contains the correct value.
> 
> The Embperl version is 1.3b2, modperl 1.21, Apache 1.3.9
> The error occurs on Linux (Debian), Linux (Mandrake with
> self build Apache etc.) and on HP-UX
> 
> Any suggestions?
> 
> Andre
> 
>   ------------------------------------------------------------------------
>    Part 1.2Type: application/pgp-signature
> 
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org

--
__________________________________________________________
Mr. Erich L. Markert                     emarkert@pace.edu
Computer Learning Center		 TEL (914)422-4328
Pace University
1 Martine Ave
White Plains, New York 10606-1932

Those who do not understand Unix are condemned to reinvent it, poorly.
                -- Henry Spencer

RE: weird problem with arrays

Posted by Gerald Richter <ri...@ecos.de>.
>
> ok, it is my'ed.
>

Look's like you are running into a closure problem (see man perlfaq7), try
to without the my

Gerald


Re: weird problem with arrays

Posted by Andre Landwehr <an...@gmx.net>.
On Mon, May 15, 2000 at 08:54:26PM +0200, Gerald Richter wrote:
> > my @starter;
> > ... since @starter is global ...
> 
> is it glocbal or local (my'ed) ?

ok, it is my'ed. 

> >
> > The Embperl version is 1.3b2, modperl 1.21, Apache 1.3.9
> > The error occurs on Linux (Debian), Linux (Mandrake with
> > self build Apache etc.) and on HP-UX
> >
> Same question as in my last mail, is mod_perl build as DSO (this is the
> normal case for all Linux Distributions). If yes, upgrade mod_perl, because
> mod_perl below 1.22 has a lot of problems when build as DSO and you use Perl
> modules with XS code like Embperl. (which then shows strange behaviour, like
> the one you talked about)

Fortunately Debian has packages with statically linked
mod_perl ;-) and the Mandrake machine also has it statically,
since I had numerous problems before when I tried it as a DSO.
About the HP-UX I can't tell you anything since I am no
admin there.

My workaround now is to put the assignment of $fdat{starterx} to
@starter also into the sub, it _seems_ to work that way (at least the last
20 or so tests worked..)

Andre


RE: weird problem with arrays

Posted by Gerald Richter <ri...@ecos.de>.
> my @starter;
> ... since @starter is global ...

is it glocbal or local (my'ed) ?

>
> The Embperl version is 1.3b2, modperl 1.21, Apache 1.3.9
> The error occurs on Linux (Debian), Linux (Mandrake with
> self build Apache etc.) and on HP-UX
>
Same question as in my last mail, is mod_perl build as DSO (this is the
normal case for all Linux Distributions). If yes, upgrade mod_perl, because
mod_perl below 1.22 has a lot of problems when build as DSO and you use Perl
modules with XS code like Embperl. (which then shows strange behaviour, like
the one you talked about)

Gerald


-------------------------------------------------------------
Gerald Richter    ecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:       Tulpenstrasse 5         D-55276 Dienheim b. Mainz
E-Mail:     richter@ecos.de         Voice:    +49 6133 925151
WWW:        http://www.ecos.de      Fax:      +49 6133 925152
-------------------------------------------------------------