You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Stéphane Peiry <st...@colt.ch> on 2001/04/04 19:15:03 UTC

$udat initialisation

Hi Everybody,

Are there any known problems with $udat initialisation?

As example I have the file 'one.html' which contains the following
(Embperl code):

[-
   $hold{thing} = "Hello";
   $udat{some}  = {%hold};
-]

[+ $udat{some}{thing} +]

(I use %hold because.. I cannot initialize directly $udat as
$udat{some}{thing} = "Hello" ..  am I missing something..?)

File 'two.html' (wich I call afther one.html) contains:

[+ $udat{some}{thing} +]

Hence I would expect this last one to print out "Hello", if I
had previously made a call to 'one.html'.  But it doesnt, it
prints the following error msg:

Can't use an undefined value as a HASH reference at 
/usr/local/apache/htdocs/monitoring/two.html line 2


Anyway, if I write a third file 'three.html' wich contains
just a line more than the 'two.html':

[- $udat{blahblah} = "blahblah" -]
[+ $udat{some}{thing} +]

then it answers appropriatly "Hello" wich is what I wanted in the first 
place....
Why is it so?

Thanks for any help/infos/comments on this,
Stéphane




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: $udat initialisation

Posted by Andre Landwehr <an...@gmx.net>.
On Wed, Apr 04, 2001 at 07:15:03PM +0200, Stéphane Peiry wrote:
> [-
>    $hold{thing} = "Hello";
>    $udat{some}  = {%hold};
> -]
> 
> [+ $udat{some}{thing} +]
> 
> (I use %hold because.. I cannot initialize directly $udat as
> $udat{some}{thing} = "Hello" ..  am I missing something..?)

That part should work, at least it did for me... %udat is in no
way different from a normal hash

> File 'two.html' (wich I call afther one.html) contains:
> 
> [+ $udat{some}{thing} +]
> 
> Hence I would expect this last one to print out "Hello", if I
> had previously made a call to 'one.html'.  But it doesnt, it
> prints the following error msg:
> 
> Can't use an undefined value as a HASH reference at 
> /usr/local/apache/htdocs/monitoring/two.html line 2

Changes in a hash (or any other list-type) in %udat are not
saved because mod_perl (I think it was mod_perl here, not
Embperl) does not see the change. I suppose it only checks values
directly in %udat and therefore sees the same reference to your
anonymous hashtable regardless if you changed something there or
not. %udat is only saved when something on the first level
changes. A workaround for your problem would be to do a
$udat{dummy}++ after any statement like
$udat{some}{thing}="Hello". Another way is to structure your data
differently, e.g. use $udat{some_thing}="Hello". 
I don't like the behaviour either but when I asked a long time
ago I was told that it's not that easy to change and that this is
just the way it is for the moment.

> Anyway, if I write a third file 'three.html' wich contains
> just a line more than the 'two.html':
> 
> [- $udat{blahblah} = "blahblah" -]
> [+ $udat{some}{thing} +]
> 
> then it answers appropriatly "Hello" wich is what I wanted in the first 
> place....

I suppose the request for three.html was answered by the same
Apache child as one.html, which still had the values somewhere
and therefore could return them to you.

Maybe I'm completely wrong with my explanations, this is just my
guess about what happened. For a more reliable answer you will
have to wait for Gerald to return, which should be in very few days.

Andre

--
 /"\
 \ /
  X  ASCII Ribbon campaign against HTML E-Mail
 / \


Re: $udat initialisation

Posted by ___cliff rayman___ <cl...@genwax.com>.
___cliff rayman___ wrote:

> the tied %udat does a shallow check to see if anything
> needs to be stored.  i think most of us who use it do something
> like this in code that changes %udat:
> $udat:{TIME}=time;

s/://

>
>
> this guarantees that the shallow check will be successful and
> that the tied %udat is stored in the session.
>
> you can invoke a session write directly if you prefer, see the
> documenation.
>
> --
> ___cliff rayman___cliff@genwax.com___http://www.genwax.com/
>
> Stéphane Peiry wrote:
>
> > Hi Everybody,
> >
> > Are there any known problems with $udat initialisation?
> >
> > As example I have the file 'one.html' which contains the following
> > (Embperl code):
> >
> > [-
> >    $hold{thing} = "Hello";
> >    $udat{some}  = {%hold};
> > -]
> >
> > [+ $udat{some}{thing} +]
> >
> > (I use %hold because.. I cannot initialize directly $udat as
> > $udat{some}{thing} = "Hello" ..  am I missing something..?)
> >
> > File 'two.html' (wich I call afther one.html) contains:
> >
> > [+ $udat{some}{thing} +]
> >
> > Hence I would expect this last one to print out "Hello", if I
> > had previously made a call to 'one.html'.  But it doesnt, it
> > prints the following error msg:
> >
> > Can't use an undefined value as a HASH reference at
> > /usr/local/apache/htdocs/monitoring/two.html line 2
> >
> > Anyway, if I write a third file 'three.html' wich contains
> > just a line more than the 'two.html':
> >
> > [- $udat{blahblah} = "blahblah" -]
> > [+ $udat{some}{thing} +]
> >
> > then it answers appropriatly "Hello" wich is what I wanted in the first
> > place....
> > Why is it so?
> >
> > Thanks for any help/infos/comments on this,
> > Stéphane
> >
> > ---------------------------------------------------------------------
> > 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

--
___cliff rayman___cliff@genwax.com___http://www.genwax.com/



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: $udat initialisation

Posted by ___cliff rayman___ <cl...@genwax.com>.
the tied %udat does a shallow check to see if anything
needs to be stored.  i think most of us who use it do something
like this in code that changes %udat:
$udat:{TIME}=time;

this guarantees that the shallow check will be successful and
that the tied %udat is stored in the session.

you can invoke a session write directly if you prefer, see the
documenation.

--
___cliff rayman___cliff@genwax.com___http://www.genwax.com/

Stéphane Peiry wrote:

> Hi Everybody,
>
> Are there any known problems with $udat initialisation?
>
> As example I have the file 'one.html' which contains the following
> (Embperl code):
>
> [-
>    $hold{thing} = "Hello";
>    $udat{some}  = {%hold};
> -]
>
> [+ $udat{some}{thing} +]
>
> (I use %hold because.. I cannot initialize directly $udat as
> $udat{some}{thing} = "Hello" ..  am I missing something..?)
>
> File 'two.html' (wich I call afther one.html) contains:
>
> [+ $udat{some}{thing} +]
>
> Hence I would expect this last one to print out "Hello", if I
> had previously made a call to 'one.html'.  But it doesnt, it
> prints the following error msg:
>
> Can't use an undefined value as a HASH reference at
> /usr/local/apache/htdocs/monitoring/two.html line 2
>
> Anyway, if I write a third file 'three.html' wich contains
> just a line more than the 'two.html':
>
> [- $udat{blahblah} = "blahblah" -]
> [+ $udat{some}{thing} +]
>
> then it answers appropriatly "Hello" wich is what I wanted in the first
> place....
> Why is it so?
>
> Thanks for any help/infos/comments on this,
> Stéphane
>
> ---------------------------------------------------------------------
> 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