in reply to eval that doesn't exec?

Well, maybe this is what you want:
# store a reference to a sub my $coderef = sub { print shift || "Foo"; print "\n"; }; # execute code, with or without arguments $coderef->(); $coderef->('Bar'); $coderef->();
It also works if you need to eval a string, then you can do like this:
my $code =<<'CODE'; print shift || "Foo"; print "\n"; CODE my $coderef = eval"sub{$code}";

You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

Replies are listed 'Best First'.
Re: Re: eval that doesn't exec?
by dsheroh (Monsignor) on May 11, 2002 at 17:43 UTC
    chromatic's answer looks like it's probably what I want, but, just to be sure, I'm looking for a way to store code in a database, pull it out as needed, and repeatedly execute it without needing to recompile on each execution.
      Well, maybe you would want to look at B::Bytecode or Storable then. :)
      You have moved into a dark place.
      It is pitch black. You are likely to be eaten by a grue.
        So I can freeze sub ref's and store it, to later retrieval and execution?