7/4 Is there something like a macro in Perl? Couldn't find any in
the Camel book.
\_ If you truly need macros in Perl, you probably want AUTOLOAD.
Of course, if you truly need macros, Perl is the wrong language for
what you are doing. -- ilyas
\_ I don't know perl, but don't almost all interpreted languages have
some kind of eval function? If so, you don't really need macros;
you can build up a string and evaluate it.
\_ There is eval in perl, and yes I know I can use eval, but it
is highly inefficient as the same code gets recompiled N times.
\_ Standard motd answer: tell us what you're actually trying to do
and we'll tell you the right way to do it instead of what you
think you want to do.
\_ What I want to do is pretty simple. Assume Perl had #define
then what I want to do would be like
#define myMacro(a) if (flagP) {a} else {foo}
Basically I want macro as a time saving device, rather than
than the all powerful macro featured in Lisp.
\_ Why don't you just run your Perl source files through
the c pre-processor?
\_ Would cpp conflict with Perl's grammar? |