Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Beginner who has a question

Status
Not open for further replies.

chadz001

Programmer
Dec 4, 2002
1
GB
I am just starting to learn perl, and using it to do cgi scripts.

I was just wondering if anyone could kindly help me:

Is is possible / how can you, pass variables between scripts?

Say for example, you have one script in which is used to input a string, called 'name'. And then you have another script that will be able to use that variable and it's set value.

Like if the variable 'name' was set to 'bob', how can you pass that onto another script.

I hope that this makes sense, and I apologise for my poor understanding in this subject.

Thank You.
 
If I understand the question, you are trying to post
CGI parms from one piece of code to another piece of
CGI code.

The following piece of code 'POST's some CGI parms
to the second peice of code which writes them to a
file.

Code:
#!/usr/local/bin/perl
use strict;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new(env_proxy => 1,
                              keep_alive => 1,
                              timeout => 30,
                            );	
$ua->post('[URL unfurl="true"]http://your_server.com/cgi-bin/LWP/catch.cgi',[/URL]
	[
	first 	=> 'john',
	last	=> 'smith',
	year	=> '1963'
	]);


This would live at and would catch and write the CGI parms to disk,
Code:
#!/usr/local/bin/perl
use strict;
use CGI;
my $o = new CGI;
open(OPF,">post_out.txt") or die "Failed to open OPF, $!\n";
my $first = $o->param('first');
my $last = $o->param('last');
my $birth = $o->param('year');
print OPF "FIRST: $first LAST: $last YEAR: $birth\n";
close OPF;
'hope this helps

If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top