use strict; use Data::Dumper; tie my $foo, 'Demo', qw(Testing one two three); print Dumper($foo); package Demo; sub TIESCALAR { my $class = shift; bless [@_], $class; } sub FETCH { my $self = shift; wantarray ? @$self : $self->[0]; }