Solved

Passing an Array as an Input to perl

Posted on 2003-12-11
8
1,783 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 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

733 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