Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl subroutine from a webpage?

         

wjbarton

2:50 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Hi there. Can a specific subroutine from a Perl script be launched from a web page or form action? I know how to launch a perl script, but is there some syntax to start with a particular subroutine, maybe something in html like:

<form name="myForm" method="post" action="myPerl?starthere">

That's just a guess, but hopefully it will explain what I'm looking for.

Thanks!

- WJB

volatilegx

3:28 pm on Mar 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, you have the right idea. What you have to do is access the $ENV{'QUERY_STRING'} environment variable. This variable contains what you have put after the? in the action property of your form tag.

Your code would look something like this:

$command = $ENV{'QUERY_STRING'};
&someSubroutine if $command eq "foo";
&someOtherSubroutine if $command eq "bar";

Alternatively, you could even execute a different subroutine based on the contents of a hidden or non-hidden form field.

Dan

wjbarton

4:33 pm on Mar 5, 2004 (gmt 0)

10+ Year Member



Dude you rock. I used the hidden input field named "Update" and created an "if (!($input{Update})) {}" logic area in my perl script. Nice!

Thanks man,

- WJB