I, certainly, always use lexical filehandles, and only noticed what follows, while poking with a stick at couple lines of code trying quick examples for foreach $1

The open explicitly states:

If FILEHANDLE is an undefined scalar variable (or array or hash element), a new filehandle is autovivified, meaning that the variable is assigned a reference to a newly allocated anonymous filehandle. Otherwise if FILEHANDLE is an expression, its value is the real filehandle. (This is considered a symbolic reference, so use strict "refs" should not be in effect.)

The print only says:

FILEHANDLE may be a scalar variable containing the name of or a reference to the filehandle, thus introducing one level of indirection.

And it also dies under use strict "refs" in case of "name".

Some of other built-ins seem to be quite tolerant (but why?) to expression producing a "symbolic reference"; what's worse is that their descriptions use what I'd call "vague" language.

close: FILEHANDLE may be an expression whose value can be used as an indirect filehandle, usually the real filehandle name or an autovivified handle.

(please, what's "unusual"?)

seek: FILEHANDLE may be an expression whose value gives the name of the filehandle

(that's clear enough)

readline: Reads from the filehandle whose typeglob is contained in EXPR

(actually, no -- EXPR also may give a name (and use strict "refs" doesn't matter). Or wait... Do they mean EXPR "contains typeglob" if it resolves to its name? English is not my mother tongue and I'm confused... H-mm)

read skips discussing what FILHANDLE may be alltogether... And so on.

Tangentially related, e.g. closedir dies angrily if expression resolves to plain string. Somewhat un-perlish, not "fail silently".


In reply to (Some) inconsistencies with IO built-ins, their documentation and filehandle names ("symbolic references") by vr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.