There's more than one way to do things | |
PerlMonks |
Re: Calling a sub from a buttonby gryphon (Abbot) |
on Oct 25, 2002 at 21:48 UTC ( [id://208156]=note: print w/replies, xml ) | Need Help?? |
Greetings cal, Fortunately (from a security perspective) you can't just run Perl subs via HTML. You'll need to pass your action request via HTTP to your CGI that will interpret it and run the function that you desire. The HTML might look something like:
Then you're Perl might something look like:
Whatever you do, don't be tempted to do something like:
UPDATE: The above assumes two things: first that you'll print out the HTTP header elsewhere in your script before sending HTML, and second that the "action" CGI parameter is always defined. If it's not, then you'll get a warning. In such cases, you could use:
This just makes sure that the parameter is defined. If it isn't or if it is and contains badness, then $action results in an empty string. gryphon
In Section
Seekers of Perl Wisdom
|
|