Hi!
A HERE document is a very fine feature of Perl that makes it easy to handle
long, multi-line strings. Like so:
print << "MYLABEL";
All
of
this
rubbish
will
be
printed
including
the
line wraps
until it finds
MYLABEL
- the word 'MYLABEL' won't print anymore. It's just a signal, that the end
of the string is HERE (I guess that's why they call it a HERE-Document, for
it will consider things as a string until HERE...)
Of course, usage is not limited to printing - you might also use it, e.g.,
to set a variable to the value of that string, just like:
my $var = << "MYLABEL";
This
will
be
it's
value!
MYLABEL
Please keep in mind that:
- the label has to be placed in A LINE OF IT'S OWN at the very beginning of
the line - with no white space before or after it, but in a LINE (that's
important if you place this label in the last line of a script: hit ENTER
after that!)
- The quoting style of the label itself will affect things like variable
resolution:
print << "MYLABEL";
will resolve variables' values etc., while
print << 'MYLABEL';
won't.
BTW what books do you have? There's a very comprhensive section on this at
the beginning of the Camel Book.
Sascha
----------
>Von: Tina Messmann <[EMAIL PROTECTED]>
>An: [EMAIL PROTECTED]
>Betreff: What is a HERE Document?
>Datum: Don, 19. Jul 2001 12:26 Uhr
>
> Hi All,
> could someone please explain to me what a HERE Document is?
> I can't find it in my books.
>
> Regards
> Tina
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]