#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use Mypackage; sub callingTest { my $object = new Mypackage(); return [ 200, [ "Content-Type" => "text/html" ], [ $object->test() ] ]; }; print Dumper callingTest(); __END__ $ perl main.pl $VAR1 = [ 200, [ 'Content-Type', 'text/html' ], [ 'from test' ] ]; #### package Mypackage; sub new { my $class = shift; my $self = {}; bless $self, $class; return $self; } sub test { return "from test"; } 1;