#!/usr/bin/perl use Dog; my @pack = create_dogs(15); sub create_dogs #of course, this should possibly be a method of Dog, but whatever { my $num = shift; map Dog->new, 1 .. $num; # or 0, whichever makes you happy. }