in reply to dynamic sub routine definitions?

Hmm, one additional question though. Is there a way to do something like "require" but on a scalar variable? So let's say I read in this module file into $the_mod. I can't obviously just say "require $the_mod"... Thanks for any more ideas. If this isn't easy, then I'll just use it as a file, but it would be slightly nicer to do this in a variable for the way I'm setup. Thanks!

Justin

Replies are listed 'Best First'.
Re: Re: dynamic sub routine definitions?
by perrin (Chancellor) on Jul 17, 2002 at 03:32 UTC
    perldoc -f eval. Also, beware of eval'ing, use'ing, require'ing, or do'ing downloaded code, even if you think you know where it came from. There are about a billion ways to exploit a program like that.
Re: dynamic sub routine definitions?
by Abigail-II (Bishop) on Jul 17, 2002 at 12:43 UTC
    Hmm, one additional question though. Is there a way to do something like "require" but on a scalar variable? So let's say I read in this module file into $the_mod. I can't obviously just say "require $the_mod"
    my $mod = "Carp.pm"; require $mod; Carp::croak ("Oh yes, you can.\n");

    Abigail

      Thanks again! I wasn't clear enough though in my question. What I mean was, if I have $var set to some big long string that is really a function (not a file name) then could I then say something like "require $var"?

      Justin Eltoft

      "If at all god's gaze upon us falls, its with a mischievous grin, look at him" -- Dave Matthews

        No, but you can use eval.

        Abigail