Link to home
Start Free TrialLog in
Avatar of vtumati
vtumati

asked on

Passing an Array as an Input to perl

Hi,
I need to pass an array as an input to an perl script something like this
sending file
<a href="testsum_pc.pl?path=$path" target="pathcommand">Path</a>
receiving file
$path_command=$q->param('path');
print "$path_command \n";

that works when i send a small string, I tried to send a big array with various special charcters. Only part of the arrray seems have to have passed rest of it got truncated
sending file
<a href="testsum_pc.pl?path=@command" target="pathcommand">Path</a>
receiving file
@path_command=$q->param('path');
print "@path_command \n";

when i do this only part of the input is transmitted.

Can i get some code on how to exactly pass an array with special charcters as input to another perl script.

-V
Avatar of Tintin
Tintin

Why do you want the result in an array?  Just using a simple scalar will be fine.

Are you encoding the "special" characters in the path?
ASKER CERTIFIED SOLUTION
Avatar of mrh30
mrh30

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vtumati

ASKER

I dont really care for the result to be an array all I want to do is to display the value. I want to be able to send an array as an input to another perl script and I want to display the sent value.
-V
Avatar of vtumati

ASKER

Let me rephrase my question all I want to do is to send the value in @command to another perl script so I can print it on the webpage. The @command array has a lot of "specialCharcters"
Please include code.

-V
What I put in above will work for what you said.
Avatar of vtumati

ASKER

I tried it and all i get is the first word in the array the second word happens which is does not work -abcd

This is the code i Used

<FORM METHOD="post" ACTION="testsum_pc.pl" target="pathcommand">
<INPUT NAME="command"> <P>
<INPUT TYPE="HIDDEN" NAME="COMMAND" VALUE=@command>
<INPUT TYPE="submit" VALUE="Command"> <P>
</FORM>

@command = $q->param('COMMAND');
print "@command \n";

When i just ran the script from the command line, the VALUE field had all the contents of @command, am i doing something wrong.

-V
If I was you I'd create the hidden input by using the interface provided in CGI.pm as I described above (almost copy and paste the code).  That's the way the documentation says to do it! :-)
Avatar of vtumati

ASKER

Here is the What my final form looked like

page1
<FORM METHOD="post" ACTION="testsum_pc.pl" target="pathcommand">
<INPUT TYPE="HIDDEN" NAME="COMMAND" VALUE=/'@command'>
<INPUT TYPE="submit" VALUE="Command"> <P>
</FORM>

page2
@command = $q->param('COMMAND');
print "@command \n";

I was missing the '  ' on the command