in reply to Re (tilly) 1: how can I access code ref contents, not call it?
in thread how can I access code ref contents, not call it?

I strongly second tilly's suggestion. Text is *the* portable medium for Perl code. If you have an eval(), why not use it.

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com

  • Comment on Re: Re (tilly) 1: how can I access code ref contents, not call it?
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re (tilly) 1: how can I access code ref contents, not call it?
by knight (Friar) on Jan 04, 2001 at 23:23 UTC
    If you have an eval(), why not use it.

    Quoting.

    Creating a complex subroutine in text gets decidedly non-trivial and hard to maintain when you have to remember to not escape $foo because you want it interpolated but to escape \$bar because it's a local variable in your text's code. For many situations, a good old anonymous subroutine reads a lot cleaner.

    Cons actually already supports Perl code snippets in text, so this is an empirical observation. Both approaches do have their advantages and disadvantages. (Besides, providing both mechanisms would give people More Than One Way To Do It... :-)