The other day I quoted a couple of paragraphs out of perlop relating to how the 'stuff' within angle brackets gets parsed. Ever since then this has bugged me, as I believe it's a mistaken omission in perlop. Here are the paragraphs in question. I've underlined the sentence that's bothering me.
If what's within the angle brackets is neither a filehandle nor a simple scalar variable containing a filehandle name, typeglob, or typeglob reference, it is interpreted as a filename pattern to be globbed, and either a list of filenames or the next filename in the list is returned, depending on context. This distinction is determined on syntactic grounds alone. That means <$x> is always a readline() from an indirect handle, but <$hash{key}> is always a glob(). That's because $x is a simple scalar variable, but $hash{key} is not--it's a hash element.
One level of double-quote interpretation is done first, but you can't say <$foo> because that's an indirect filehandle as explained in the previous paragraph. (In older versions of Perl, programmers would insert curly brackets to force interpretation as a filename glob: <${foo}> . These days, it's considered cleaner to call the internal function directly as glob($foo), which is probably the right way to have done it in the first place.)
I think it should say...
...but you can't say <"$foo"> because...
The sentence is discussing what happend when you double-quote the contents of the angle bracket operator, but gives an example that isn't double-quoted. This is a subtle omission, but it damages the clarity of the assertion. Readers have to reflect on the gory details of quoting to realize the implications since the double-quotes are omitted from the example given.
Before I submit a perlbug report and patch I just wanted to confirm with the PerlMonks that I'm on the right channel. Comments welcomed...
Dave
In reply to Subtle omission in perlop? by davido
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |