use strict; use warnings; my @array = (1 .. 4); for my $element (@array) { print "[$element]"; push @array, $element / 2 if (!($element % 2)); }