#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; { package MyObj; use overload '""' => \&both, fallback => 1; sub new { my ($class, $first, $last) = @_; bless { first => $first, last => $last }, $class } sub first { $_[0]->{first} } sub both { "@{ $_[0] }{qw{first last}}" } } sub makeupname { 'MyObj'->new(qw(John Smith)); } say makeupname(); say makeupname()->first;