heredoc

Calling PHP functions within HEREDOC strings

In PHP, the HEREDOC string declarations are really useful for outputting a block of html. You can have it parse in variables just by prefixing them with $, but for more complicated syntax (like $var[2][3]), you have to put your expression inside {} braces. In PHP 5, it is possible to actually make function calls within {} braces inside...

Unable to cat Ruby blocks to files

Please help, I am stuck here --- irb> a = "line of text\n line two\n line three" irb> system("cat > test_file << #{a}") cat: of: No such file or directory cat: text: No such file or directory => false ...

How to inline few java lines inside an Ant script?

How to inline (here-document) few java code lines into a Ant script ? Please an example ? ...

Working with large text snippets in Java source

Are there any good ways to work with blocks of text (Strings) within Java source code? Many other languages have heredoc syntax available to them, but Java does not. This makes it pretty inconvenient to work with things like tag libraries which output a lot of static markup, and unit tests where you need to assert comparisons against blo...

What is the best way to have long string literals in Javascript?

Possible Duplicate: Multiline strings in Javascript In Ruby you can do something like this temp = <<-SQLCODE select * from users SQLCODE This way you have very long string literals in your code without have to escape lots of characters. Is there something similar in JavaScript? Currently I have javascript code like this, an...

heredoc for Windows batch?

Is there a way of specifying multiline strings in batch in a way similar to heredoc in unix shells. Something similar to: cat <<EOF > out.txt bla bla .. EOF The idea is to create a customized file from a template file.. ...

PHP <<<EOB

I've been developing with PHP for some years now, and recently came across this code: <?php echo <<<EOB <html> <head> <title>My title</title> </head> ... EOB; ?> I've never seen this approach to print HTML, which seems to be pretty useful and less prone to some weird variable or double quote syntax error. I've...

How make an "here document" in Ant?

How to write an Ant script as: ... ... begin of HERE DOCUMENT > ./outfile.txt xxx toto yyy zzz end of HERE DOCUMENT ... ... Of Whom the execution creates a file called ./outfile.txt Whom contains: xxx toto yyy zzz ...

How to assign a heredoc value to a variable in Bash?

I have this multi-line string (quotes included) abc'asdf" $(dont-execute-this) foo"bar"'' How would I assign it to a variable using a heredoc in Bash? There is still no solution that preserves newlines. I don't want to escape the characters in the string, that would be annoying... ...

heredoc with eval code execution

I've tryed a couple of methods to try and get this working but with no luck! I've got a page like this (Example): <?php $jj = <<<END ?> <h1>blah blah</h1> <p> blah blah blah blah blah blah blah <?php include("file.php"); ?> blah blah</p> <?php END; eval('?>'.$jj.'<?php '); ?> this causes no output what so ever, can not think of a sol...

Python subprocess with heredocs

I was playing around with Python's subprocess module, trying a few examples but I can't seem to get heredoc statements to work. Here is the trivial example I was playing with: import subprocess a = "A String of Text" p = subprocess.Popen(["cat", "<<DATA\n" + a + "\nDATA"]) I get the following error when I run the code above: cat: <<...

Heredoc this PHP-HTML

I'm trying to heredoc the following code: <?php //some php //some more php if (some condition) { ?> <label>CMKS1<?php echo $CMKS1_CMKS2_space; ?>CMKS2</label> <input name="cmks1" type="text" class="base-cls <?php if ($err1) echo "err-cls"; ?>" /> <input name="cmks2" type="text" class="base-cls <?php if ($err2) echo...

PHP syntax error T_ENCAPSED_AND_WHITESPACE

hello all! i'm starting to work with php basics and i have some problem understanding how mix code with strings. I found a great and useful style to print string blocks but i don't know the name and i'm not able to find examples. the code below return me the error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expect...

Can you declare a variable in ASP classic like this?

I am trying to see if this can be done in classic ASP: Dim myVar myVar = <<< END <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>test</title> </head> <BODY> END I can do this in PHP, but I am not positivte if it can be done in ASP. Problem is I need to handle the HTML output via a variable, and I...

Using <<<CON in PHP

What is the effect of the following code: $page = <<<CON <p><center>Blah blah blah</center></p> CON; What does the <<<CON do? ...

Heredocs - Using same name twice? Why name them at all?

Toying with heredocs in PHP, I realized the name of the heredoc does not have to be unique. Thus: $a = <<<EOD Some string EOD; $b = <<<EOD A different string EOD; is correct and behaves exactly as you would expect. Is this bad practice for any reason? Why does a heredoc need a name/label (EOD above) at all, since you can't referen...

Exporting MySQL to Excel

Hi, I need some help with this code from PHP Classes, that's supposed to export MySQL to Excel. I'm getting the following error: Parse error: syntax error, unexpected T_SL in excelwriter.inc.php on line 100 This is line 100: [Line100] function GetHeader() { $header = <<<EOH <html xmlns:o="urn:schemas-...

Extracting gettext translations from PHP heredoc syntax?

I'm using PHP's gettext functions for doing localization. I'm using Poedit to do the actual translation, and with its "Update from sources" feature it is really easy to extract all the strings that need to be translated - except from inside heredoc syntax. Poedit is using the xgettext program to generate the .po files from the PHP sourc...

HEREDOC interfering with code indentation

I like the HEREDOC syntax, e.g. for edge cases of generated HTML that are not worth putting into a template. The only thing that annoys me about it, though, is that the content, and the closing marker of a heredoc string adheres to the first column. This screws up nested code layouts: class myclass { function __construct() ...

How can I escape code-like things in a Perl string?

Hi, this code: $i=1; while($i<3) { print << "EOT"; def px$i = new E(user) if (!px$i.hasErrors()) { println "${px$i.name} / ${px$i.empr.to} OK" } EOT $i++; } produces the error: Can't call method "px" without a package or object reference at borrar.pl line 3. How can I "escape" the if ? Thanks....