in reply to Open Function Question
So a "heredoc" just makes a string! There is no "open" involved, it is just a string like any other string. If you want to iterate over a number of constant values in your program, there are other ways:print <<END; This is some long winded window text that could appear somewhere and using this heredoc allows me to type it in without having to double quote it or put in "." concatenations or "\\n" characters as this will be printed verbatim just like it is except note that I had to double escape the newline! Otherwise it would be a "newline"! END
There are a number of variations on open() which I think have been covered quite well below. I didn't know before that $somevar could be opened as a a RAM file (a memory resident temp file) in Perl 5.8. I've always just generated a "real" temp file in the past.while (<DATA>) { chomp; #just to show you what the \n is there #just like from a file.. print "$_\n"; } __DATA__ thing1 thing2 thing3
You cannot write to a "heredoc", nor to the DATA filehandle.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Open Function Question
by bichonfrise74 (Vicar) on Apr 18, 2009 at 16:05 UTC |