use strict;
use warnings;
my @list = (4,5,6,7,1,2,3);
my @x;
my @y;
my @z;
my $bin = 0;
foreach my $e ( @list ) {
if ( $bin == 2){
unshift @z, $e;
$bin = 0;
} elsif ( $bin ) {
push @y, $e, $e+1;
$bin = 2;
} else {
push @x, $e;
$bin = 1;
}
}
print "x is: @x\n";
print "x is: @y\n";
print "z is: @z\n";
this is perl. I just don't get the part from my $bin ; to the end of the foreach loop... can someone please explain. Thanks.
use warnings;
my @list = (4,5,6,7,1,2,3);
my @x;
my @y;
my @z;
my $bin = 0;
foreach my $e ( @list ) {
if ( $bin == 2){
unshift @z, $e;
$bin = 0;
} elsif ( $bin ) {
push @y, $e, $e+1;
$bin = 2;
} else {
push @x, $e;
$bin = 1;
}
}
print "x is: @x\n";
print "x is: @y\n";
print "z is: @z\n";
this is perl. I just don't get the part from my $bin ; to the end of the foreach loop... can someone please explain. Thanks.