home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!sdd.hp.com!usc!sol.ctr.columbia.edu!destroyer!ubc-cs!unixg.ubc.ca!news
- From: andy@orchid.bdc.ubc.ca (Andrew Dwelly)
- Newsgroups: comp.lang.perl
- Subject: Arrays of filehandles
- Message-ID: <1992Aug12.230411.20069@unixg.ubc.ca>
- Date: 12 Aug 92 23:04:11 GMT
- Sender: news@unixg.ubc.ca (Usenet News Maintenance)
- Organization: University of British Columbia, Vancouver, B.C., Canada
- Lines: 32
- Nntp-Posting-Host: orchid.bdc.ubc.ca
-
-
- I am writing a script which works on a number of files (1 .. n) which
- must all be opened at the same time for reading. I'd like to write
- something like
-
- # This bit does work,
-
- foreach $i (0 .. $#ARGV)
- {
- open(@filehandle[$i],"<".@ARGV[$i]) || die "Can't open @ARGV[$i]\n";
- }
-
- # But this bit just falls through as if @filehandle[0] was empty
- while (<@filehandle[0]>)
- {
- ....etc etc
-
- I need to get various lumps of data from <@filehandle[$whatever]> in the
- rest of the code.
-
- As you might guess, this doesn't work in the above form. I've looked
- at the camel book and the man page, and I realize I've bumped into
- the idirect filehandle issue, but - sorry Larry - I didn't understand
- the explanation as you can see.
-
- What should I be doing here. Also, what is the difference between an
- array @this[$that] and $this[that] ? this has also been troubling
- me in the last few days.
-
- All advice gratefully received.
-
- Andy Dwelly (andy@bcu.ubc.ca)
-