In html form, I can write <form method=post action=sample.pl>....</form>
How can I call a subroutine in "sample.pl" from this form?
It doesn't work if I write <form method=post action=sample.pl?subname>...</form>
You can add a hidden field to the form. When the form is submitted, use the value in an if...else statement. If the hidden field exists, go to the subroutine desired.
A method involving ?name=value is a query string and applies to method="get", not "post." You could still apply the above suggestion to such, ?subroutine_trigger=call_sub_name. But better to make it a post, otherwise all form values will be carried in the query string in the browser window.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.