On 7/17/2004 2:08 AM, gohaku wrote:
Hello everyone, After months of searching perl documentation and books, I finally found out what those "<<" are called. What's strange is that I found my answer in a PHP book!
Having seen heredocs in a php script first, I find Perl's syntax very confusing.
The following works as a php script but not as a perl script (removed <?php and ?>):
print <<<HTML <head> <title>heredoc demo</title> </head> HTML;
From the sparse examples that I could find with heredocs and perl, the former php script
finally becomes a perl script:
print <<HTML; <head> <title>heredoc demo</title> </head> HTML
...onto the questions:
1.) What's up with the semicolon at the end of the first delimiter? I find that confusing.
statement terminator. It ends the statement. A more obvious example would be somthing like:
sub myfunc { my $str = shift; # do something with $str; return str; }
print myfunc(<<HTML); <head> <title>heredoc demo</title> </head> HTML
Above you can see that the semicolon is only there to end the statement that contains the here-document.
2.) No documentation was found for [perldoc heredoc] and [perldoc heredocs],
where is the documentation or examples that illustrate how to use heredocs in perl?
perldoc perldata perldoc perlop
search for 'here-doc'
3.) How are heredocs stored in variables?
here-documents just provide a simple way of representing strings. there is nothing special about them.
Thanks in advance. -gohaku
Regards, Randy.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>