Naming a package 0 is a fatal, compilation error ... The problem is likely to occur where, in some code completely separate from yours, someone writes '$x->your_method()' when, perhaps, '$y->your_method()' was intended.
Another example might be auto-generated package names (though if such code generated a package named "0", one could question the sanity of that choice...)
use warnings; use strict; { package Foo; use Data::Dump; use Scalar::Util qw/blessed/; sub new { return bless {}, shift } sub foo { my $self = shift if blessed($_[0]) && $_[0]->isa(__PACKAGE__); dd 'foo', $self, \@_; } sub bar { my $self = shift if defined blessed($_[0]) && $_[0]->isa(__PACKAGE__); dd 'bar', $self, \@_; } } { no strict 'refs'; @{"0::ISA"} = ('Foo') } my $x = bless {}, '0'; $x->foo(); # ("foo", undef, ["0=HASH(0x561239194f3e)"]) $x->bar(); # ("bar", "0=HASH(0x561239194f3e)", [])
In reply to Re^5: Calling module function from within a blessed module
by haukex
in thread Calling module function from within a blessed module
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |