Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: undefing *foo{CODE} does not fully work

by brian_d_foy (Abbot)
on Apr 13, 2006 at 04:18 UTC ( #542992=note: print w/replies, xml ) Need Help??

in reply to undefing *foo{CODE} does not fully work

It seems to work if you undefine *foo instead of undefining $x. If you want to undefine something, you have to undefine it (and not undefine something else).

print "Undefining foo()"; undef *foo; print "Foo is not defined" unless defined &foo;
brian d foy <>
Subscribe to The Perl Review

Replies are listed 'Best First'.
Re^2: undefing *foo{CODE} does not fully work
by ikegami (Pope) on Apr 13, 2006 at 05:03 UTC

    While that and works, it also undefines @foo, %foo, etc. It seems to me that the OP is trying to undefined &foo specifically.

    Other working solutions with the same caveat:

    my $x = \*foo; undef *$x;


    my $x = 'foo'; { no strict 'refs'; undef *$x; }


    my $x = do { no strict 'refs'; \*{'foo'} }; undef *$x;
Re^2: undefing *foo{CODE} does not fully work
by jesuashok (Curate) on Apr 13, 2006 at 04:24 UTC

    $x = *foo; undef &$x;
    Is the above statement is wrong ? If so, give me your valuable inputs, so that I can be on safer side from my other developers.
    Because I was the one who has done this in the initial stage.

    "Keep pouring your ideas"

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://542992]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2018-07-17 02:41 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (353 votes). Check out past polls.