in reply to return Both ARRAY and SCALAR

use 5.010; use strict; use warnings; package Foo; use overload '""' => sub {${$_[0]}{SCALAR}}, '@{}' => sub {${$_[0]}{ARRAY}} ; sub XX { bless {SCALAR => 'one', ARRAY => ['two', 'three']}, shift; } package main; my $y = Foo->XX; say join ", ", $y, @$y; __END__ one, two, three

Replies are listed 'Best First'.
overload.pm is perfect for the job
by FutureBoyNil (Initiate) on May 07, 2009 at 14:45 UTC
    This is exactly what I was looking for. Thank you very much!