home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / perl / 5345 < prev    next >
Encoding:
Text File  |  1992-08-17  |  1.5 KB  |  42 lines

  1. Newsgroups: comp.lang.perl
  2. Path: sparky!uunet!decwrl!access.usask.ca!kakwa.ucs.ualberta.ca!unixg.ubc.ca!news
  3. From: andy@orchid.bdc.ubc.ca (Andrew Dwelly)
  4. Subject: Re: Arrays of filehandles
  5. Message-ID: <1992Aug17.162710.23327@unixg.ubc.ca>
  6. Sender: news@unixg.ubc.ca (Usenet News Maintenance)
  7. Nntp-Posting-Host: orchid.bdc.ubc.ca
  8. Organization: University of British Columbia, Vancouver, B.C., Canada
  9. References: <l8o27cINNocq@jethro.Corp.Sun.COM>
  10. Date: Mon, 17 Aug 1992 16:27:10 GMT
  11. Lines: 29
  12.  
  13. In article <l8o27cINNocq@jethro.Corp.Sun.COM> eric.arnold@Sun.COM (Eric  
  14. arnold) writes:
  15. > but I am also puzzled about why this doesn't work:
  16. >     $fh_gen = "FH000";
  17. >     for ( 1..25 ){ push( @a, $fh_gen++ ) ; }
  18. >     open($a[0],"<one");
  19. >     while (<$a[0]>)
  20. >     {
  21. >         print;
  22. >     }
  23.  
  24. Larry was kind enough to mail me with the answer. Apparently
  25. the angle bracket notation is quite strict about what it will accept,
  26. anything apart from <thingy> or <$thingy> is regarded as 
  27. a file glob. 
  28.  
  29. In my more complex script I found that even this form causes 
  30. problems so in the end I avoided the whole problem by writing a 
  31. metaprogram. It reads the names of the files to be worked on,
  32. assigns an ordinary filehandle to each one then writes out
  33. a second program that does the actual job. Then it just
  34. executes the second program.
  35.  
  36. The metaprogram is a bit complicated to read because it's full of
  37. escapes, but the generated program is quite simple and extremely fast.
  38. My user is happy so I'm happy as well.
  39.  
  40. Andy (andy@bcu.ubc.ca)
  41.