perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andre Landwehr <>
Subject Re: $udat initialisation
Date Wed, 04 Apr 2001 18:20:37 GMT
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.


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

View raw message