Dave Howorth has asked for the wisdom of the Perl Monks concerning the following question:
produces:#!/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;
That's all as I expect except the last call of can returns a code address that no longer works, and leads to a run-time error if used. I would have expected can to return undef on that occasion.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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: can undefined methods?
by Joost (Canon) on Nov 29, 2004 at 13:08 UTC | |
by Dave Howorth (Scribe) on Nov 29, 2004 at 15:02 UTC | |
|
Re: can undefined methods?
by Anonymous Monk on Nov 29, 2004 at 16:05 UTC |