home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5287 < prev    next >
Encoding:
Internet Message Format  |  1992-08-12  |  1.4 KB

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