Perl-Sensitive Sunglasses | |
PerlMonks |
RE: File handles in an objectby gnat (Beadle) |
on Jul 12, 2000 at 00:43 UTC ( [id://22104]=note: print w/replies, xml ) | Need Help?? |
You'll have to do two things. (1) As pointed out by others, <SOMETHING> is ambiguous. It's either a filehandle read or a directory glob (to get the list of files that match a pattern:
As the comments there say, the rule is: If it's a simple scalar variable, it's a filehandle. If it's a bare word it's a filehandle. Anything else and it's a directory glob. So you'll need to use a temporary variable:
(2) You won't be able to successfully open more than one file (even if you hadn't hard-coded the filename :-). A common hack in Perl to get filehandles in arrays or hashes or subroutines is to use typeglobs, because Perl lets you use a scalar containing a typeglob anywhere you would normally use a filehandle. However, there's some cunning required when opening the file:
This gives you two copies of the same glob in @filehandles. What you need to do is create a new glob each time. The best way to do this is with local():
Good luck! Nat
In Section
Seekers of Perl Wisdom
|
|