Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: dynamic sub routine definitions?

by Eradicatore (Monk)
on Jul 17, 2002 at 03:17 UTC ( [id://182312]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://182312]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-20 12:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found