in reply to Re^3: How to remove the actual glob from a glob reference
in thread How to remove the actual glob from a glob reference

You cant delete the typeglob while a reference to it still exists (fro +m $a or $b). You can however make it undefined, (freeing up any IO ha +ndles etc attached to it) with the following:
Thanks for giving me a solution, I have understood, but I have one more question, Let us consider the below code,
open $a, "/etc/passwd" or die "can't open /etc/passwd: $!\n"; { local $/ = undef; $userdetails = <$a>; print ">>",$userdetails,"<<\n"; } close($a); # this closes the filehandle print "A>",$a ,"<\n"; # this prints a glob # .... (assume that some lines of code lies here) # .. ######################################################### # in some other part of the program, How do I check whether # the filehandle associated with the handle is still open? # I have done it this way, if(defined fileno($a)), # because fileno(filehandle) will return undef if there is # no filehandle associated with it. # Is any other ways exist to check the above problem?. #########################################################

Replies are listed 'Best First'.
Re^5: How to remove the actual glob from a glob reference
by dave_the_m (Monsignor) on Oct 06, 2008 at 14:08 UTC
    You probably want
    if (!eof($a)) ...

    Dave.

      eof() will check for next read on filehandle will return end of file, is there any function to check whether the next write on the filehandle will return end of file?.

        A write will never return end of file, it'll return an error. On my system, it's error 9, "Bad file descriptor". Are you asking how to check if the file is still opened? if defined(fileno($a))