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

please help me using *glob{FILEHANDLE} How/where/why it is used? Please give me example.

Replies are listed 'Best First'.
Re: *glob{FILEHANDLE}
by broquaint (Abbot) on Jun 18, 2003 at 11:00 UTC
    There are only 6 globs slots and they are SCALAR, ARRAY, HASH, IO, FORMAT and CODE, so I can only assume by *glob{FILEHANDLE} you mean *glob{IO}. The *glob{IO} slot holds the reference to the IO object associated with a glob's filehandle (assuming it exists) e.g
    open(FH, $0); print "*FH IO slot holds - ", *FH{IO}, $/; __output__ *FH IO slot holds - IO::Handle=IO(0x8107e4c)
    Not meaning to plug (but will anyway) I'd recommend Of Symbol Tables and Globs for more info on globs and glob slots.
    How/where/why it is used? Please give me example.
    Accessing glob slots directly is very rarely done, and when it is, it's usually for doing low-level code like writing Exporter type code. Here's a simple demo of such code (if somewhat contrived)
    sub import { my $pkg = caller; ## import only filehandles *{"$pkg\::$_"} = *{__PACKAGE__."::$_"}{IO} for keys %{__PACKAGE__."::"}; }

    HTH

    _________
    broquaint

    update: s/DIR/CODE/ + added example

      perl 5.8 Release document says The *glob{FILEHANDLE} is deprecated, use *glob{IO} instead. What changes i need to make in my script to make it work in 5.8 version.
        What changes i need to make in my script to make it work in 5.8 version.
        If you explicitly access the FILEHANDLE glob slot then just change it to access the IO slot, otherwise you don't have to do anything. Note that this only a warning and won't actually change the operation of your code, but as with most warnings they're best heeded.
        HTH

        _________
        broquaint