in reply to Storing the bytecode compiled with eval()
This is off the top of my head, so you may have to play around with it slightly.my $sub <<SUB; sub { print "I've been compiled once! I'm anonymous!\n"; } SUB my $sub_ref = eval $sub;
If you're looking for a way to compile a string once and have that persist across invocations of the program, you'll have to look into something like B::Bytecode, which is experimental and may not gain you very much.
Other options include normal anonymous subroutines and closures. There's probably a way to get around most specific problems there, but knowing how to eval an anonymous subroutine into existence can occasionally come in handy.
|
|---|