launching a Perl script ....

  • Follow


I can launch a Perl script when a user clicks a submit button on a
form...... and I can launch a Perl script when a user clicks on a
link..... but..... can I launch Perl script A from Perl script B ????

The reason it seems like a good idea is that script B puts up a
form.... and the form potentially needs to be brought up at various
points in a session, and I'd like to do it in one place.....


Thanks in advance,
Will

0
Reply wdflannery (23) 3/30/2005 3:06:13 AM

joesplink wrote:
> I can launch a Perl script when a user clicks a submit button on a
> form...... and I can launch a Perl script when a user clicks on a
> link

Well, the most ordinary way to launch a Perl script is by simply typing its 
name on the command line and hitting ENTER.

>..... but..... can I launch Perl script A from Perl script B ????

Is there anything wrong with system() or exec() or backticks?

jue 


0
Reply J 3/30/2005 4:04:57 AM


joesplink wrote:

> I can launch a Perl script when a user clicks a submit button on a
> form...... and I can launch a Perl script when a user clicks on a
> link..... but..... can I launch Perl script A from Perl script B ????
> 
> The reason it seems like a good idea is that script B puts up a
> form.... and the form potentially needs to be brought up at various
> points in a session, and I'd like to do it in one place.....

What I usually do in cases like this is have a library file containing all
common subroutines etc and then just load that at the beginning of each
program with require. Then you can make a subroutine that returns the form
(or at least the non-changing parts of the form) and just call it.

If doing this, make sure that your library file returns 1 when it is loaded
with require. The easiest way to do this is to ensure that the last piece
of code within it is

1;

Or if you want you can create a package :-).

Hope this helps

Andrew Bryson
http://www.bryson.co.nz


0
Reply Andrew 3/30/2005 4:13:20 AM

On 29 Mar 2005 19:06:13 -0800, joesplink <wdflannery@aol.com> wrote:
> I can launch a Perl script when a user clicks a submit button on a
> form...... and I can launch a Perl script when a user clicks on a
> link..... but..... can I launch Perl script A from Perl script B ????
> 
> The reason it seems like a good idea is that script B puts up a
> form.... and the form potentially needs to be brought up at various
> points in a session, and I'd like to do it in one place.....

You really should post CGI questions in a CGI newsgroup.

But what I usually do is use a single script to generate the initial form
on $ENV{REQUEST_METHOD} eq "GET", and process or go to the next form if
not (doesn't matter if POST or post or Post), with previous data as hidden
fields.  I determine what to do next based on the name of the submit
button.
0
Reply efflandt 3/31/2005 12:18:17 AM

joesplink wrote:
> can I launch Perl script A from Perl script B ????

Depends on whether script_A is designed to be called from the
command line as opposed to only running in the CGI environment.

   $result = `perl script_A args=B`;	# If not CGI
   use LWP::Simple;
   $result = get("http://server/cgi-bin/script_A?args=B");

	-Joe
0
Reply Joe 3/31/2005 11:51:12 AM

Thanks, I tried it using LWP::Simple ... didn't work (for reasons
unknown ... and now I've got an alternate design that doesn't depend on
it), but it's good to know its there.

0
Reply joesplink 4/2/2005 2:58:09 AM

5 Replies
95 Views

(page loaded in 0.082 seconds)


Reply: