1. You can insert any perl code into the currently running program using "eval STRING". Like this:
Note that truly malicious code can leave your main program in an incomplete state or even force your program to quit. See also Safe and eval.my $code = 'print "stuff\n"'; # in your example this would be read fr +om STDIN. eval $code; # <- eval STRING, not eval { BLOCK } $@ and warn "Found an error: $@";
Perl doesn't really compile into bytecode, or at least not like Java does. You can currently mess with the compiled code in the interpreter, but it gets complicated fast and there are few reasons to do it.
2. The compiled code normally stays in memory. If you really want to you can save the interpreter state/bytecode to a file but that's not well supported and all my personal attempts to use it for anything have failed miserably. See perlcc.
If you want some sort of "binary distribution" (i.e. one executable file instead of perl interpreter and many modules/scripts) take a look at PAR.
update: fixed link to PAR.
In reply to Re: About Embedding Perl Codes on a Current Running Program
by Joost
in thread About Embedding Perl Codes on a Current Running Program
by PerlPhi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |