$Bill Luebkert wrote: > Suresh Govindachar wrote: > >> Hello, >> >> |use warnings; >> |use strict; >> | >> |# Question: In the following, any suggestions for ensuring >> |# that $stuff will be " Twice 3 is 6"? >> |# >> |# For example, if the here-document were re-written >> |# to be something like: >> |# Twice $foo is eval{2*$foo} >> |# how would one "escape" the eval so that it would >> |# indeed evaluate its contents? >> |# >> |my $foo = 3; >> | >> |my $stuff = <<here_doc; >> | Twice $foo is 2*$foo >> |here_doc >> | >> |__END__ > > Either evaluate it before the here doc and use a simple vrbl or > you could use this tricky syntax: > > my $stuff = <<EOD; > Twice $foo is @{[2 * $foo]} > EOD I have been evaluating the expressions before the here doc, and felt there might be a better way of evaluating inside the here doc itself.
But what does "use a simple vrbl" mean? You mean a verbal description? Thanks for @{[]} -- it is better than evaluating outside the here doc. This is because the expressions I need to evaluate are fairly complex and the variables involved come from hashes. Moreover, I would like to do assignments inside the here doc that do not show up in $stuff at all, for example: |my $foo = 3; |my %boo=(); | |my $stuff = <<EOD; | @{[eval{$boo{hoo1}=5; "remove_me";}]} | Twice $foo is @{[2 * $foo]} | Second line | @{[eval{$boo{hoo2}=2; "remove_me";}]} | Third line says that \$boo{hoo1} is $boo{hoo1}. |EOD | |$stuff =~ s/\s*remove_me\s*$//gm; What is the name for the @{[]} thingie -- how can it be found in perldoc? And is there a way to avoid the remove_me part? --Suresh _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs