#!/usr/bin/env perl use strict; use warnings; my @f; # Modification of your code for my $i (0..2) { my @e = ($i+2, $i+1); push @f, [@e]; } # A more succinct way to achieve it for my $i (3..5) { push @f, [$i+2, $i+1]; } # For demo purposes use Data::Dump; dd \@f; #### [[2, 1], [3, 2], [4, 3], [5, 4], [6, 5], [7, 6]]