Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Passing an Array as an Input to perl

Posted on 2003-12-11
8
Medium Priority
?
1,793 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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
Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

 

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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

636 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