Solved

Passing an Array as an Input to perl

Posted on 2003-12-11
8
1,756 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:vtumati
  • 4
  • 3
8 Comments
 
LVL 48

Expert Comment

by:Tintin
ID: 9926255
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?
0
 
LVL 3

Accepted Solution

by:
mrh30 earned 500 total points
ID: 9928040
If you really want to pass the array across, you're better off setting up a CGI parameter with the sending script as follows:

$q->param(-name=>'path', -value=>@command);

This will need to be within a form and you'll need to submit the form, but you'll then have the data available to you.  In the recieving script you'll want to have something like:

@values = $q->param('path');

Although to be honest, I suspect you'll probably be able to get round this without having to pass arrays around from the sounds of it.
0
 

Author Comment

by:vtumati
ID: 9929401
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
0
 

Author Comment

by:vtumati
ID: 9929437
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
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Expert Comment

by:mrh30
ID: 9929506
What I put in above will work for what you said.
0
 

Author Comment

by:vtumati
ID: 9929680
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
0
 
LVL 3

Expert Comment

by:mrh30
ID: 9929689
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! :-)
0
 

Author Comment

by:vtumati
ID: 9930239
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
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The viewer will learn how to count occurrences of each item in an array.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now