Re: deprecated methods

[prev] [thread] [next] [Date index for 2004/11/26]

From: Dave Howorth
Subject: Re: deprecated methods
Date: 17:25 on 26 Nov 2004
> Is it possible for an application to undefine these methods so it can 
> use them?

Perhaps I should add that doing the obvious cure of undefining the 
method doesn't work because UNIVERSAL::can() doesn't seem to notice. So 
even though the method has disappeared and causes an error when called, 
can() still indicates that it's there. So:

#!/usr/bin/perl
use strict;
use warnings;

BEGIN { print "can=", __PACKAGE__->can('fred'), ";\n"; }
sub fred { print "fred\n"; }
print "can=", __PACKAGE__->can('fred'), ";\n";
fred;
undef &fred;
print "can=", __PACKAGE__->can('fred'), ";\n";
fred;

produces:

Use of uninitialized value in print at test.pl line 5.
can=;
can=CODE(0x81199b4);
fred
can=CODE(0x81199b4);
Undefined subroutine &main::fred called at test.pl line 11.

All of which is as I would expect except the second can= line.
Calling the code reference that can() returns also produces the 
undefined subroutine error, so can() really seems to be wrong (or more 
likely I'm being very dense :). It does get it right if I redefine &fred.

I'm running Perl 5.6.1.

Cheers, Dave

deprecated methods
Dave Howorth 14:06 on 26 Nov 2004

Re: deprecated methods
Dave Howorth 17:25 on 26 Nov 2004

Re: deprecated methods
Yuval Kogman 18:35 on 26 Nov 2004

Re: deprecated methods
Dave Howorth 14:28 on 29 Nov 2004

Generated at 11:34 on 01 Dec 2004 by mariachi v0.52