--- [EMAIL PROTECTED] wrote:
> I created a first simple program to append code to itself (script
> below). Is there a way to get that code interpreted in the same
> execution? That didn't happen, but when I started it a second time,
> the first appended text was interpreted, the second again not.

Peerl is not strictly "interpreted", as a lot of languages are; once
the script it running, editing it doesn't change what the program will
do. In that, it's more like a compiler.

What exactly is your goal here? Do you want to execute dynamic code, or
change the program, or both? You've already seen that changing the
program file will alter subsequent runs, but not the current one. For
dynamic code, use eval(), like this:

 my $code = "print 'Hi.'";
 eval $code;
 die $@ if $@; # look at eval() documentation for more detail. 

> main code
> filename: prg2.pl
> 
> print"prg2 part1 \n\n";
> open (DAT,">>prg2.pl") || die"failure:\n$!";
> print DAT "\n#Appendix";
> print DAT "\nprint\"prg2 part2\";";
> close (DAT);

   

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/

Reply via email to