in reply to Bareword "FILE" not allowed while "strict subs"
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.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Bareword "FILE" not allowed while "strict subs"
by revdiablo (Prior) on Oct 08, 2004 at 22:59 UTC |