You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Darren Greer <dg...@websightsolutions.com> on 2000/08/01 22:44:30 UTC

Question on param, and hashes

Ok...

We have been using Embperl since b2.  I have just recently upgraded a
server to b4, and now I can no longer pass a hash as "param => \%param"
to Embperl::Execute.  I then installed b3 on the server to test it, and
the same problem occurs.  So, I re-installed b2, and all is well now. 
Is there something I am missing here?

Also, Is there a way to pass multiple hashes to the templates?

Any help would be appreciated,

Thanks,

Darren

-- 
Darren Greer
System Administrator / Application Development Manager
Websight Solutions Inc. - Web Sites With Vision
p 262.790.9327 f 262.790.5952 toll-free 877.790.9327

Re: Question on param, and hashes

Posted by Darren Greer <dg...@websightsolutions.com>.
> param takes a array ref and _not_ a hash ref. Embperl makes a alias
between
> the array you pass to param and the @param array inside the page and I
could
> not image how this could have worked. Also I am not aware that I have
> changed anything between b2 and b3 for the parameter passing.
>
> To pass an hash do
>
> param => [ %hash ]
This makes complete sense, and I will try it immediately.  However, I assure
you you can pass it by reference the way I tried in b2.  But it is a moot
point.  Thank you for the correction.

Darren



Re: Question on param, and hashes

Posted by Gerald Richter <ri...@ecos.de>.
>
> We have been using Embperl since b2.  I have just recently upgraded a
> server to b4, and now I can no longer pass a hash as "param => \%param"
> to Embperl::Execute.  I then installed b3 on the server to test it, and
> the same problem occurs.  So, I re-installed b2, and all is well now.
> Is there something I am missing here?
>
> Also, Is there a way to pass multiple hashes to the templates?
>

param takes a array ref and _not_ a hash ref. Embperl makes a alias between
the array you pass to param and the @param array inside the page and I could
not image how this could have worked. Also I am not aware that I have
changed anything between b2 and b3 for the parameter passing.

To pass an hash do

param => [ %hash ]

and inside your page

%hash = @param ;

but much mor effective is to simply pass the hash reference:

param => [ \%hash ]

and in the page

$hashref = $param[0] ;

This work also for multiple hashs:

param => [ \%hash1, \%hash2, \%hash3 ]

and in the page

($hashref1, $hashref2, $hashref3) = @param ;

Of course you can pas also other scalars, not only hashs.

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
-------------------------------------------------------------