in reply to RE: eval output
in thread eval output

What I am writing is a small indexing program for my website. Sort of similar to the function of Everything, but a little simpler. What I want is when someone pulls up "index.pl?webpage=main_page" that page is a CGI script, and I want to run, and have it display its output.

I think I know how to do,a nd I was going to use eval -- instead of require. But does eval use variables that have already been declared before the eval has been called.

Sorry this is a lot to ask, but you asked to explain it... Oh yeah Thanks...

I am the first overweight, very tall munchkin... be very amazed.

Replies are listed 'Best First'.
RE: RE: RE: eval output
by Fastolfe (Vicar) on Nov 10, 2000 at 23:24 UTC
    Any eval statement does its execution in the current context and scope. Any variables that are available to code in the current scope are also available to code you eval, and any changes to those variables done in your eval block persist after it's over.
    my $code = '$a = 2;'; # $a is meaningless here; it's just a string sub hi { my $a = 1; eval $code; print "$a\n"; # 2 }