#!/bin/perl package first; use strict; use warnings; sub new{ my $class = shift; my $type = shift; return bless \$type, $class; } sub greet { my $type = shift; print "\n hello got something .. $$type \n"; } 1; package AFactory; use strict; use warnings; sub get_new { my $class = shift; my $type = shift; return $class->new(@_); } 1; my $greeter = AFactory->get_new("first","dow dow"); $greeter->greet(); print "hellow\n";