#!/usr/bin/perl
# Hitomezashi pattern generator by polprog
use strict;

unless($#ARGV > -1){
	print "How big do you want your pattern to be?\n";
	exit 1;
}
my @ROWS; #
my @COLS; # arrays which hold the rows and cols generator values

for (1..$ARGV[0]){
	push @ROWS, int rand 2;
	push @COLS, int rand 2;	
}

my $rownum = 0; # row and column numbers
my $colnum = 0; # for generation 

# Place a vertical stich if the current row is even and the start value
# is odd or if the current row is od and the value is even - XOR
# same for columns, place a horizontal stich only if the generator is
# different than the current column
for my $row (@ROWS){
	$colnum = 0;
	for my $col (@COLS){
		
		if($rownum % 2 xor $col) { print ":"; }
		else { print " "; }
		if($colnum % 2 xor $row) { print "_"; }
		else { print " "; }	
		$colnum++;
	}
	print "\n";
	$rownum++;
}
