in reply to Passing arguments to functions.

What is a "function module"? An example of what $command actually contains would help.

I recommend passing a code reference as first argument, this is the most generic way to solve this kind of problem.

use 5.010; use strictures; sub execute_command { my ($code, $params) = @_; say 'Inside executeCommand'; say 'Currently executing: ', ref $code; foreach my $element (@{ $params }) { say "Parameter: $element"; $code->($element); } } my $command = sub { # I am going to print the arguments I receive! say @_; }; execute_command($command, \@paramlist);

Replies are listed 'Best First'.
Re^2: Passing arguments to functions.
by balajinagaraju (Sexton) on Apr 25, 2012 at 11:29 UTC
    Hi, Thanks for your reply, i will try your approach and let you know the results. $command is a normal perl function , it might do anything as you defined it can just print the passed arguments as well. In my case $command is a value got by parsing an xml which is a name of a function.. $command = launchapp; launchapp is the function name which needs to be triggered.