You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by John Sydnor <sy...@sycomm.com> on 2001/08/30 00:36:20 UTC
Help with Execute - param and passing arrays
Hi,
I'm having trouble passing arrays to Execute.
Passing parameters to my page component:
Execute ({inputfile => $CSI_common."displayresponder.html", param =>
[$bgcolor1,$bgcolor2,$textcolor,@records]});
Reading the parameters in my page component:
[-
$bgcolor1 = $param[0];
$bgcolor2 = $param[1];
$textcolor = $param[2];
@records = $param[3];
-]
The first 3 scalars work fine but embperl only resolves the first element of
my @records array(@records has 16 elements).
I've searched the docs and mailing list to no avail.
What am I missing?????
Thanks,
John
Re: Help with Execute - param and passing arrays
Posted by "Luiz Fernando B. Ribeiro" <li...@athome.pro.br>.
Olá John,
Reply:
JS> I'm having trouble passing arrays to Execute.
JS> Passing parameters to my page component:
JS> Execute ({inputfile => $CSI_common."displayresponder.html", param =>
JS> [$bgcolor1,$bgcolor2,$textcolor,@records]});
JS> Reading the parameters in my page component:
JS> [-
JS> $bgcolor1 = $param[0];
JS> $bgcolor2 = $param[1];
JS> $textcolor = $param[2];
JS> @records = $param[3];
JS> -]
JS> The first 3 scalars work fine but embperl only resolves the first element of
JS> my @records array(@records has 16 elements).
When you say $param[3] you are putting in @records just the 4th
element of @param, try this:
($bgcolor1, $bgcolor2, $textcolor, @records) = @param;
This should work as you expect.
Bye,
Luiz Fernando B. Ribeiro
----------------------------
At Home - Design e Internet
contato@athome.pro.br
athome@uol.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Help with Execute - param and passing arrays
Posted by Wim Kerkhoff <wi...@merilus.com>.
Hey John,
I'll reply as I've just finished fighting through learning how to pass
scalers and hashes via param. I'd have responded sooner if you hadn't
posted in email, though.
I believe you need two pass your @records array by reference.
Pass the parameters:
[-
@records = qw(one two three);
Execute ("display.html", $bgcolor1,$bgcolor2,$textcolor,\@records);
-]
Read the parameters in display.html:
[- ($bgcolor1, $bgcolor2, $textcolor, $records) = @param -]
Now you can use $records as an arrayref:
[$ foreach $record (@$records) $]
print stuff<br>
[$ endforeach $]
Or, convert $records from an arrayref back into an array (ie, now you
have two copies in memory):
[- @records = @$records -]
Hope that helps.
Wim
---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org