in reply to About Embedding Perl Codes on a Current Running Program

A couple of answers. Note: I haven't really read all your code, but it seems to be a bit too complicated for what you're trying to achieve. It's a bit hard to tell what you're trying to achieve exactly, though. :-)

1. You can insert any perl code into the currently running program using "eval STRING". Like this:

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: $@";
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.

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.