[EMAIL PROTECTED] wrote: > Hi - > > I am grinding through =Programming Perl= and came to the section on Here > Documents in Chapter 2 (forgive me, I can't think of the term "Here documents" > without thinking that there must be a dog somewhere named Documents). > > Anyhoo, I tried typing some of the examples at the keyboard. They stick in my > memory better that way. I'm wondering why > > print << x 10; > The camels are coming! > > only seems to work if there is a blank line (e.g. a carriage return) after the > string to be printed. If I don't put that blank line in, I get the error > > Can't find string terminator anywhere before EOF at ./perlcamel.pl line 3 >
Hi Kevin. The text of a 'here' document is everything up to a line containing the string following '<<' on a line on its own (with a terminating newline). You can delimit that string with quotes (in which case it can be any text you want) but if you don't it will be delimited by the first whitespace after '<<'. I tour example your '<<' is immediately followd by a space, so the terminating text is a null string (a blank line). I you enable warnings you will get the message Use of bare << to mean <<"" is deprecated which is basically telling you that if you really mean a null string you should make it visible. With quotes, any amount of whitespace is allowed before or after the string, like this: print << "TRAIN" x 10; The camels are coming! TRAIN but a non-null string straight after the '<<' is more usual: print <<TRAIN x 10; The camels are coming! TRAIN (Note that this code is indented by two spaces. The actual terminating string must be flush left.) HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]