The <...> operator can mean ...->readline() or glob("..."). Perl has to decide which of those two you wanted. <BAREWORD> always means readline() as glob("BAREWORD") isn't very useful. <*.c> always means glob() since "*.c" isn't ever going to be a file handle.
Now, things like <$scalar>, <$array[0]>, <$hash{KEY}> were harder to call. For some reason that I'm not completely sure of, it was decided that the first would always be readline() and all others would be glob(). I think this is generally acknowledged as not an ideal design decision, but we are stuck with it.
So I tend to never use <> when I mean glob() and to write $hash{KEY}->readline() when my file handles aren't simple like <FILE> or <$fh>. I was surprised to find Perl smart enough to make this work even when I didn't create file handles with an IO::* module. I'm not sure how smart it is, though, so using a module is probably a good idea.
- tye (but my friends call me "Tye")In reply to (tye)Re: Please explain: A hash of file handles peculiarity
by tye
in thread Please explain: A hash of file handles peculiarity
by ghor
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |