There is always something new to learn

IlyaM on 2003-07-15T14:07:13

Today I learned a variation of HERE-docs syntax I didn't know about before:

print <<;
text text text
text text text

print <<''; text text text text text text



I always thought that a stop word is required in HERE-docs.


Wow

VSarkiss on 2003-07-15T14:54:32

That first one sure looks weird. I can't justify calling it a bug, but perldata clearly states

Following a << you specify a string to terminate the quoted material ...
While I could argue that '' is a legitimate string, I can't say the same for. (See that null string just before the period?)

Re:Wow

IlyaM on 2003-07-15T15:18:12

It is documented in perlop:

Following a "<<" you specify a string to terminate the quoted material, and all lines following the current line down to the terminating string are the value of the item. .... There must be no space between the "<&lt" and the identifier, unless the identifier is quoted. (If you put a space it will be treated as a null identifier, which is valid, and matches the first empty line.)

But wait! There's more!

dws on 2003-07-15T15:28:40

Try print and print if you want to be explicit about interpolation.

I saw this done once in production code, and I took it out.

Re:But wait! There's more!

dws on 2003-07-15T15:29:46

Arg. Make that print <<''; and print <<"";