dorimes has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I added an open file and close file on the following line, and got the following message : Not a GLOB reference at RebuiltLoadFiles.pl line 48. The lines are : open(GENERAL_LOG,">$generalFile"); close{GENERAL_LOG}; Anyway, the file was created. Does anybody know what is the problem ?

Replies are listed 'Best First'.
Re: Not a GLOB refernce
by broquaint (Abbot) on Feb 10, 2003 at 11:15 UTC
    Does anybody know what is the problem?
    When in doubt, B::Deparse it out
    shell> perl -MO=Deparse - open(GENERAL_LOG,">$generalFile"); close{GENERAL_LOG}; open GENERAL_LOG, ">$generalFile"; close *{{'GENERAL_LOG'}}; - syntax OK
    So there you're passing an anonymous hash to close which it the tries to dereference as a glob and subsequently fails. As others have suggested you need to use parentheses instead of curly brackets.
    HTH

    _________
    broquaint

Re: Not a GLOB refernce
by Heidegger (Hermit) on Feb 10, 2003 at 07:55 UTC
    You should use 'normal' brackets () for a function call: close{GENERAL_LOG};. Since you're using {}, it thinks it's a variable and says there is no such reference ("Not a GLOB reference at"). So, you made a typo ;-)

    PodMaster has just told me that perl doesn't think it's a variable. Perl actually "creates an anonymous hash, and passes it's reference to the close function. perl -MData::Dumper -e die(Dumper{1..10})".

Re: Not a GLOB refernce
by rdfield (Priest) on Feb 10, 2003 at 10:37 UTC
    It might be a good idea if you used a larger (or even a completely different) font when developing: you would probably have not made such an error.

    rdfield