Home > Archive > PERL Beginners > November 2005 > about deleting subroutine
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
about deleting subroutine
|
|
| Jennifer Garner 2005-11-21, 9:56 pm |
|
hi,lists,
I have seen this thread on perlmonk,and it make me too.Can anyone here explain that?Thanks.
Quote:
-------
Basically, deleting subroutines from a symbol table seems a bit buggy, but I
don't know if this behavior is documented or not.
#!/usr/bin/perl -l
sub this { 'this' }
print this;
undef &main::this; # undefine the code slot
print main->can('this') ? 'main->can("this")' : '! main->can("this")';
eval {print this};
print $@;
undef *main::this; # undefine the entire glob
print main->can('this') ? 'main->can("this")' : '! main->can("this")';
__END__
# result
this
main->can("this")
Undefined subroutine &main::this called at sub.pl line 7.
! main->can("this")
The first time I try to remove the subroutine via undef it still leaves a
CODE slot in the symbol table's *this glob. I can't just use delete because it's
not an array or a hash (it fails if you try). This is bad in procedural code but
it's awful in OO code because $object->can('this') will succeed even if the
method has been deleted.
This leaves me with having to undefine the entire glob but that's a
horrible solution because the other slots in the glob, if any, are blown away.
Is this a known/documented bug/feature in Perl? Is there a workaround?
| |
| John W. Krahn 2005-11-21, 9:56 pm |
| Jennifer Garner wrote:
> hi,lists,
Hello,
> I have seen this thread on perlmonk,
And you thought that the people on the beginners list would be more
knowledgeable than the people on perlmonks.org?
> and it make me too.Can anyone here explain that?
Explain why it makes you ? No.
John
--
use Perl;
program
fulfillment
| |
| Randy W. Sims 2005-11-21, 9:56 pm |
| Jennifer Garner wrote:
> hi,lists,
Hi Jennifer,
> I have seen this thread on perlmonk,and it make me too.Can anyone here explain that?Thanks.
>
> Quote:
> -------
> Basically, deleting subroutines from a symbol table seems a bit buggy, but I
> don't know if this behavior is documented or not.
Bug #37128: undefing *foo{CODE} does not fully work
<http://rt.perl.org/rt3/Ticket/Display.html?id=37128>
Randy.
| |
| Jennifer Garner 2005-11-22, 3:56 am |
|
hi,Randys,
Bug #37128: undefing *foo{CODE} does not fully work
<http://rt.perl.org/rt3/Ticket/Display.html?id=37128>
When I try to access that url,it require me to be verified by username and passwd.
So I can't access that url.
On Mon, 21 Nov 2005 22:30:00 -0500, "Randy W. Sims" <ml-perl@thepierianspring.org> wrote:
> Jennifer Garner wrote:
>
> Hi Jennifer,
>
> anyone here explain that?Thanks.
> but I
>
> Bug #37128: undefing *foo{CODE} does not fully work
>
> <http://rt.perl.org/rt3/Ticket/Display.html?id=37128>
>
> Randy.
| |
| Randy W. Sims 2005-11-22, 3:56 am |
| Jennifer Garner wrote:
> hi,Randys,
> Bug #37128: undefing *foo{CODE} does not fully work
>
> <http://rt.perl.org/rt3/Ticket/Display.html?id=37128>
>
> When I try to access that url,it require me to be verified by username and passwd.
> So I can't access that url.
username: guest
passwd: guest
Randy.
|
|
|
|
|