package My; use overload ('0+' => 'num_conv'); sub new { my $self = shift; bless {}, ref($self) || $self; } sub num_conv { undef } package main; my $var = My->new; print int($var);