For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > December 2005 > Passing variables-values from one *.pl file to another









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Passing variables-values from one *.pl file to another
Adam Smith

2005-12-02, 9:55 pm

I have a site - With several uniquely ID'd members

FreeBSD - 4.9
Apache/1.3.31 (Unix)
perl-5.8.2 w/ CGI.pm installed

Some members intermittently may perform a transaction using a perl
application suite that accepts data input via several Forms.
The data is processed, creates and computes new variable-value pairs
and generates several *.html files. These need to be processed again
in another *.pl file.

These files (*.html) all contains form(s), and I need to pass
these variables between all of them as pre-filled or hidden
fields.

Now, I have to alert the specific member, by e-mail (sendmail/qmail)
to complete the data input of the final forms, which must now be
customized or personalized to h(im)/(er), as the information is
personal. I have generated template files that can be tagged w/
member's ID or other unique identifiers, that could be directly
linked in the email.

My main problem is - how best to pass the variables from the first
application to the the others. I'd like to do this with the least
intrusion into the main application as it's large and complex.
More importantly,I haven't figured out it's architecture,
and I don't want to break anything, especially those that I wouldn't
know is obviously broken.
Generating the personalized secondary *.html files, e-mail prompt etc.
is minor, I think, at the moment at least.

Suggestions needed.
usenet@DavidFilmer.com

2005-12-03, 7:55 am

Adam Smith wrote:
> These files (*.html) all contains form(s), and I need to pass
> these variables between all of them as pre-filled or hidden
> fields.


Are you asking:
"How do I pass parameters via http?"

GET and POST come to mind....

For example, you could do something like this:

http://my.server.com/process.this.cgi?name=foo&task=bar

and your downstream script would know those parameters, usually via the
"param" method of CGI.pm.

Is that what you're asking???????

Adam Smith

2005-12-03, 7:55 am

Not Quite!
[in a nutshell]
The first program, appl_1.pl takes up data, via forms using POST,
processes them, spits them out, along with new variables, via
appl_[1...n].html files on the fly.

Now, I'd like to capture some of these variables for additional
processing by another *.pl script.


usenet@DavidFilmer.com wrote:
> Adam Smith wrote:
>
>
>
> Are you asking:
> "How do I pass parameters via http?"
>
> GET and POST come to mind....
>
> For example, you could do something like this:
>
> http://my.server.com/process.this.cgi?name=foo&task=bar
>
> and your downstream script would know those parameters, usually via the
> "param" method of CGI.pm.
>
> Is that what you're asking???????
>

Purl Gurl

2005-12-03, 6:55 pm

Adam Smith wrote:

(snipped)

> The data is processed, creates and computes new variable-value pairs
> and generates several *.html files. These need to be processed again
> in another *.pl file.


> These files (*.html) all contains form(s), and I need to pass
> these variables between all of them as pre-filled or hidden
> fields.


Two scripts are below for your study. Research and read about
methods employed and you will understand how to accomplish
your task.

Should you want to run these, configure each script per your
system specifics, and run the first script at your command
line. Upon exit, open the created file and examine contents.

You may also use system() if you do not want to exit
your parent script for whatever reason.

Purl Gurl

test.pl (parent script)

#!perl

@Data_In = qw (data1 data2);

print "Creating an html page with data $Data_In[0]\n";

print "Creating an html page with data $Data_In[1]\n";

print "Executing script 2 with data: @Data_In";

exec ("perl test2.pl @Data_In"); # configure per your system specifics


-----


test2.pl (child script)


#!perl

open (TEST2, ">test2.txt") || die $!;

print TEST2 "I can create html pages with this sent data:\n@ARGV";

close (TEST2);
Adam Smith

2005-12-03, 6:55 pm

Thanks Purl will surely give them a try

Purl Gurl wrote:
> Adam Smith wrote:
>
> (snipped)
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com