in reply to Open Function Question

I looked again at your question and it looks to me like the problem is more a misuse of the "heredoc" rather than an open() question. A "heredoc" is often used say for a long bunch of text that you want to perhaps print or use in some other way. It is just a shorthand way of making a single string out of multi-line text.
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
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:
1. Use @stuff like this: @stuff = qw (thing1 thing2 thing3);foreach (@stuff){..blah..}
2. For some test data, use a __DATA__ segment placed after your executable code. The DATA file handle doesn't need to opened or closed - you can just read from it.
I'm saying that putting a list of file names inside of a "heredoc" is a rather weird looking thing to do.
while (<DATA>) { chomp; #just to show you what the \n is there #just like from a file.. print "$_\n"; } __DATA__ thing1 thing2 thing3
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.

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
    I understand what you are saying and when I saw the heredoc with the open function, I found it weird.
    As you pointed out, I love to use __DATA__ to test my data and have always used it.
    I was just curious as to how somehow was able to use heredoc with an open function.