Jim Gibson wrote:
On 4/30/10 Fri  Apr 30, 2010  9:27 AM, "Joseph L. Casale"
<jcas...@activenetwerx.com> scribbled:

Inside a here doc, how can I force an expression to be evaluated
such as localtime:

print <<"END";

`localtime time`
Foo
Bar
END


I know I can simply create the var before,
my $var = localtime time;

But just curious how to evaluate expressions inside this...

You can use the trick mentioned in 'perldoc -q string' "How do I expand
function calls in a string?", referencing, then dereferencing an array, but
it is ugly:

print <<"END";

@{ [`localtime time`] }
Foo Bar
END

localtime is a Perl function, not an external command, so:

print <<END;

@{[ localtime time ]}
Foo
Bar

END



John
--
The programmer is fighting against the two most
destructive forces in the universe: entropy and
human stupidity.               -- Damian Conway

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to