in reply to Re^2: set env var at compile time
in thread set env var at compile time

I think what diotalevi says is true, but I think there is still a Perl solution. I think the solution moritz gives below would work (using exec). It's very similar to what's in the link in my note above. I say all this without having tried it, of course.