On Nov 25, Lorenzo Caggioni said:
I made some changes in the program (delete eval, edjust subs... )
Now the program takes less then 3 sec but it loses all the structure...
The main thing that increase performance is delete the eval("fun name").
I do it in this way because the name of the function is retrived from a
database.
is there another way to recal a function retrining his name from a variable?
Yes, it's called a dispatch table:
my %functions = (
abc => \&do_this,
def => \&do_that,
ghi => \&do_something_else,
);
Those \&... things are REFERENCES to functions. So you do:
while (my @row = get_stuff_from_database()) {
# assuming $row[0] is abc or def or ghi
# that is, $row[0] holds the nickname of the function
my $code = $functions{$row[0]};
$code->(@arguments);
}
So when $row[0] is 'abc', we call do_this(...). Etc.
--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://www.perlmonks.org/ % have long ago been overpaid?
http://princeton.pm.org/ % -- Meister Eckhart
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>