Michael C. Davis wrote: > > Is there a way to defer evaluation of the contents of a here-doc-defined > value such that one can embed variables in the here-doc and not have them > evaluated until they are used later? Something like this: > > code: > ----- > use strict; > use warnings; > > my $header = <<'end_of_header'; > # File: $filename > end_of_header > > my $filename = 'xyz'; > print $header, "\n"; # output: want to see # File: xyz, but get # > File: > $filename > > > I tried a few variations and nothing seems to work, as shown below. (This > RFC http://dev.perl.org/perl6/rfc/229.html from Perl 6 implies that there > is fact no way to do this.) Can anyone clarify. Thank you.
i didn't check the link but from what you describe, i don't see any reason this can't be done: #!/usr/bin/perl -w use strict; my $s =<<'CODE'; I want to say: $v CODE my $v = 'hello world'; print eval qq.qq,$s,.; __END__ prints: I want to say: hello world david -- s$s*$+/<tgmecJ"ntgR"tgjvqpC"vuwL$;$;=qq$ \x24\x5f\x3d\x72\x65\x76\x65\x72\x73\x65 \x24\x5f\x3b\x73\x2f\x2e\x2f\x63\x68\x72 \x28\x6f\x72\x64\x28\x24\x26\x29\x2d\x32 \x29\x2f\x67\x65\x3b\x70\x72\x69\x6e\x74 \x22\x24\x5f\x5c\x6e\x22\x3b\x3b$;eval$; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>