- or download this
for @$r -> $x, $y {
push @$pairs, [$x, $y];
}
- or download this
my $r2;
my $flipper = 0;
...
push @$r2, [ $_ ];
}
}
- or download this
my %h=(@$r);
for (keys %h) {
...
}
# or possibly
# push @$r2, [$_, $h2{$_} ] for keys %h
- or download this
my $i = 0;
my $r2 = map {[ $r->[$i*2], $r->[$i++*2+1] ]}
(0 .. $#{$r}/2 - 1);
# or (0 .. scalar(@$r)/2 - 1)
- or download this
for( my $i=0; $i < scalar @$r; $i += 2 ) {
$r2->[$i/2] = [ @$r[$i, $i+1] ]
}
- or download this
my @copy = @$r;
for( @copy ) {
push @$r2, [ $_, shift @copy ];
}
- or download this
my @copy = @$r;
while( @copy ) {
push @$r2, [ shift @c, shift @c ];
}
- or download this
$r2 = [ map { [$r->[2*$_], $r[2*$_+1]] } 0 .. scalar @$r / 2 - 1 ]
- or download this
$r2 = [ map { [@$r[2*$_, 2*$_+1]] } 0 .. scalar @$r / 2 - 1 ]
- or download this
@copy = @$r;
while (my @pair = splice @copy, 0, 2) {
push @$r2, [@pair];
}
- or download this
#! /usr/bin/perl -w
...
},
);
__END__