in reply to Dynamically constructed function calls
Otherwise, the right side is a method name or a simple scalar variable containing either the method name or a subroutine reference, and the left side must be either an object (a blessed reference) or a class name (that is, a package name). See perlobj.
This means that you can't have a string or an expression as a method name. It has to be a simple scalar. So if you do the following, everything should work fine:
my $method = "prefix_$key"; $f->$method($atr);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Dynamically constructed function calls
by dpuu (Chaplain) on Nov 04, 2004 at 01:07 UTC | |
by ysth (Canon) on Nov 04, 2004 at 02:07 UTC | |
by dragonchild (Archbishop) on Nov 04, 2004 at 04:03 UTC | |
by ikegami (Patriarch) on Nov 04, 2004 at 04:48 UTC | |
by ysth (Canon) on Nov 04, 2004 at 05:36 UTC | |
| |
by ikegami (Patriarch) on Nov 04, 2004 at 04:37 UTC | |
by itub (Priest) on Nov 04, 2004 at 01:54 UTC |