Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

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 a log crumbles through the grate...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2017-09-24 23:44 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (275 votes). Check out past polls.