kosta has asked for the wisdom of the Perl Monks concerning the following question:

***UPDATE*** GOSH MY MIND IS PHP :D ...***UPDATE***

Dont forget that perl is not PHP, it better that is why you switched... use eq for string comparison!!! If you forget you will ask just the very same question as written below

Hi, I am trying to determine which of my submit buttons was clicked to actually submit the form... I am using CGI.pm
looks like this:
if (param('poslat') ){ print param('poslat'); if (param('poslat') == 'Schvalit_vse') { print 'schvalit_vse_clicked'; } if (param('poslat') == 'Schvalit vybrane') { my @checks = param('box'); print 'schvalit_vybrane_clicked'; foreach (@checks) { print $_; } ... submit(-name=>'poslat', -value=>'Schvalit_vse'). br. br. br. submit(-name=>'poslat', -value=>'Schvalit vybrane') ...
What happens is that all the conditions above pass (it kinda looks like all the buttons were clicked even if it was just a one) What am I missing here? ... THNX

Replies are listed 'Best First'.
Re: determine which submit was clicked
by ikegami (Patriarch) on Jan 19, 2011 at 17:34 UTC
    Using warnings and checking your error log would have given you the answer instantly.
    $ perl -e'use warnings; if ("Schvalit_vse" == "Schvalit_vse") {}' Argument "Schvalit_vse" isn't numeric in numeric eq (==) at -e line 1. Argument "Schvalit_vse" isn't numeric in numeric eq (==) at -e line 1.
Re: determine which submit was clicked
by locked_user sundialsvc4 (Abbot) on Jan 19, 2011 at 18:20 UTC

    “Come to the Light Side, Luke!   PHP is the Dark Side.   Few who have ventured there have returned with their intellects intact...   (Those that do, seem to have acquired a strange fascination with very strong Java, Rubies, and other equally useless, mind-numbing baubles...)   Do not go there, young Skywalker.”

    ;-)

Re: determine which submit was clicked
by happy.barney (Friar) on Jan 20, 2011 at 07:12 UTC
    btw, it's better to use different names for different submit buttons and test only "param exists" (it allows you to change values without strange errors ...).
    Instead of compose html chunks, try to look for template modules, for example HTML::Template or Template