http://www.perlmonks.org?node_id=996032


in reply to Math::BigInt new

$x overloads stringification, stringifying as "27". The new method presumably does something like:

sub new { my ($class, $value) = @_; bless { value => $value } => "$class"; }

Thus you end up with a reference blessed into package "27".

Generally speaking, constructors are designed to be called as class methods not object methods.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'