Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Perl/TK : Passing arguments to the function while clicking submit button

by kiruthika.bkite (Scribe)
on Apr 06, 2010 at 09:07 UTC ( #833001=perlquestion: print w/ replies, xml ) Need Help??
kiruthika.bkite has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I have designed one form(signup form) using Perl/Tk.
After getting all details in sign-up form I need to pass these values to one function and I need to validate those values in that function.

I have written the code for this.
But what is the problem is ,function get called before getting all the details in the form.

And also this problem(i.e function get called before getting details) is happening when I am calling this function with arguments.

Example
$post_button = $form_name->Button(-text=>"Post",-command=>\&Post_Artic +le($title_val,$url_val,$description_val))->place(-x=>275,-y=>430);

Comment on Perl/TK : Passing arguments to the function while clicking submit button
Download Code
Re: Perl/TK : Passing arguments to the function while clicking submit button
by choroba (Abbot) on Apr 06, 2010 at 09:23 UTC
    The correct syntax for passing arguments to subs is
    -command => [\&function,$arg1,$arg2]
      Thanks a lot..
      But I want to know why it is working when I called the function without argument and not working with argument.

      It will be better if you explain this.

      Thanks.
        why it is working when I called the function without argument

        Presumably because \&function (without parentheses) is a reference to the function, while \&function(...) is a reference to whatever the called function returned.

        #!/usr/bin/perl -l sub function { return "foo"; } $command = \&function; print $command; $command = \&function(); print "$command -> $$command"; __END__ $ ./833005.pl CODE(0x604fd0) SCALAR(0x604290) -> foo
        Could you please be more specific? (A piece of code with both expected and real output would be helpful.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://833001]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2014-10-26 01:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (149 votes), past polls