{ my $initialized; my @array; sub example { unless ( $initialized) { $#array = $size_needed; $initialized++; } # fill the array } }