Any idea why this is happening?
Amazing, no one answered the question.

In the documentation you referenced they used FILEHANDLE to mean "generic file handle". In your code you did understand correctly that FILE was your file handle . . . but how to let Perl know that?

The Perl functions like open and close expect to get a file handle as the first argument. So they automatically convert the use of a bare 'FILE' to be the use of the file handle value associated with that name. Not quite magic, but just the obvious meaning.

But when you used 'FILE' with just any old subroutine name, like restore_parameters() from the CGI.pm module, Perl didn't know what to make of it. You could have 'meant' the scalar value, the array, the hash, ... or any of the things that might have been associated with that bare name. (Think of $FILE, @FILE, %FILE, etc.)

The use of *FILE (a 'typeglob') as ikegami suggested more or less says give the whole smash to the subroutine so that it can figure out which value/meaning to use.

The use of file handle values in specific variables as BUU and bpphillips demonstrated is the most explicit way for everyone to know what is meant, for _all_ uses.


In reply to Re: Bareword "FILE" not allowed while "strict subs" by shenme
in thread Bareword "FILE" not allowed while "strict subs" by silent11

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.