in reply to Re^2: How Perl can push array into array and then how retrieve
in thread How Perl can push array into array and then how retrieve
You can compute calculate the numbers from a simple sequence:
or you can use the C-style loop to skip over the unwanted numbers:my @f; for my $i (0 .. 20) { my @e = (2 * $i, 2 * $i + 1); push @f, \@e; } print map "(@$_)", @f
or you can use grep to filter the numbers you want:for (my $i = 0; $i <= 40; $i += 2) { my @e = ($i, $i + 1); push @f, \@e; }
etc.for my $i (grep 0 == $_ % 2, 0 .. 40) { my @e = ($i, $i + 1); push @f, \@e; }
|
|---|