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