#!/usr/bin/perl use strict; use warnings; use Dog; my @pack = (); create_dog(15); foreach(@pack) { $_->bark; } sub create_dog { for (my $i=0; $i != $_[0]; $i++) { my $x = Test->new(); my $dog = \$x; push @pack, $dog; } }