Solved

Passing an Array as an Input to perl

Posted on 2003-12-11
8
1,754 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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 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

11 Experts available now in Live!

Get 1:1 Help Now