use strict; use warnings; my @powers = map{undef} 0 .. 3; my $x = 2; powers ($x, @powers); print("$x @powers\n"); sub powers { $_[$_] = $_[$_ - 1] * $_[0] for 1 .. @_ - 1; } #### 2 4 8 16 32