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

The correct syntax for passing arguments to subs is
-command => [\&function,$arg1,$arg2]
  • Comment on Re: Perl/TK : Passing arguments to the function while clicking submit button
  • Download Code

Replies are listed 'Best First'.
Re^2: Perl/TK : Passing arguments to the function while clicking submit button
by kiruthika.bkite (Scribe) on Apr 06, 2010 at 09:48 UTC
    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
        Thank you..I understand it.
      Could you please be more specific? (A piece of code with both expected and real output would be helpful.)