#!/usr/bin/perl use strict; use warnings; { package Foo; use overload '+' => sub { 'oops' }; sub new { bless {}, shift } } my $foo = Foo->new; print 0+$foo;