my ($y, $x) = (split(/ /, <>)); my $c = 1; my $rs = 1; for(1 .. $y){ $c = $rs; $out = ""; for(1 .. $x){ $out .= $c . " "; $c ^= 1; } $out =~ s/ $/\n/; print $out; $rs ^= 1; }