in reply to Opening multiple files
No, because perl can only have 256 handles open at once and they have to be named in capital letters and there are only 26 of those.
If you want to open more files you can use ruby which has first-class filehandles
or gawk which hides filehandles away so you only need to handle filenames. (Update: you could use octave if you insist on the "end for" bit.)@list #contains list filenames @handle = @list.map {|n| File.new(n) } for h in @handle @data = h.readlines end
There's also a trick (ref. 483243 and 544184) to open multiple files: `cat filename1 filename2` but that only works in unix and has to read everything to memory so I don't recommend to do it in production code.
(This reply is meant to be a bad joke. Don't take it seriously, instead read holli's reply. I think too that this is an XY problem. You can open multiple filehandles simultanously, using lexical filehandles (or Symbol). There's however no need for that if all you want is to read the data from all of them, as you can open the files sequentially: you can reuse a filehandle by reopening it (which will close the previous file).)
|
---|