in reply to How to remove the actual glob from a glob reference

now I have two typeglobs pointing to same address

No, you have two references pointing to the same (ie a single) typeglob. undef $a causes one of the references to the typeglob to be freed (the typeglob itsself is not yet freed, since $b still contains a reference to it).

If in addition you do undef $b, then the typeglob will be freed. But it's not clear to me what you are actually trying to achieve.

Dave.

Replies are listed 'Best First'.
Re^2: How to remove the actual glob from a glob reference
by targetsmart (Curate) on Oct 06, 2008 at 07:17 UTC
    Thanks for your comments and yes I got your point, I know that undef $b will do, But I need to delete $b using $a, The typeglob itself need to be freed via $a without actually using $b. Have you got it now?.
      Thanks for your comments and yes I got your point, I know that undef $b will do, But I need to delete $b using $a, The typeglob itself need to be freed via $a without actually using $b. Have you got it now?.
      "delete $b using $a" doesn't make much sense. Do you want to delete the reference $b (leaving the typeglob it refers to unchanged), or do you want to delete the typeglob itself?

      You cant delete the typeglob while a reference to it still exists (from $a or $b). You can however make it undefined, (freeing up any IO handles etc attached to it) with the following:

      undef *$a

      Dave.

        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?. #########################################################