use strict; my @foo; push @foo, Foo->new() for (0..4); package Foo; use vars qw($count); sub new { my $class = shift; $count++; print STDERR 'there are ', $count, " instances\n"; my $self = { bar => 42 }; return bless $self, $class; }