#! usr/bin/perl -w # strips makes paper strips for grilles and aritsos # MAX 10 strips: strip 1, strip 2, etc # # copyright Steve Harris 2012-14. ACA member: Ceolfrith use Term::ANSIColor; use integer; # ______________________________________ SCALARS my $i=0; my $j=0; my $step=1; # counters my $lencrypt = 0; # length of crypt my $columns = 0; # number of columns my $rows = 0; # number of rows my @chars; # array of characters my @colnums; # array of column numbers for manipulation my $newrow = ""; my $crypt=""; my $cryptfile = "stripcrypt.txt"; my $command = "Y"; # ---------------------------------------------------------------- MAIN system('clear'); print color 'bold blue'; print "\nSTRIPS.\n"; print color 'reset'; print "____________________________________________________\n"; print color 'blue'; print "Reading crypt. Please verify no spaces or non-word chars. "; print color 'reset'; open CRYPT, $cryptfile or die $!; $crypt = ; close CRYPT; chomp $crypt; $lencrypt = length $crypt; print color 'bold red'; print "\n", $crypt; print color 'reset'; print color 'bold blue'; print "\n\nLength of crypt: ", $lencrypt; @chars = split //, $crypt; # ------------------------------------------------------------ GRID FACTORS while ($command eq "Y") { last if ($command eq "N"); print color 'reset'; print color 'bold blue'; print "\n\nNumber of columns in your grid? "; $columns = ; $rows = $lencrypt/$columns; print "Number of rows is ", $rows, "\n\n"; for ($i=0; $i<$columns; $i++){$colnums[$i]= $i+1; print $colnums[$i]," ";} #initialize colnums print color 'reset'; print color 'bold red'; print "\n"; for ($i=0; $i < $rows; $i++) { $j = $i; while ($step <= $columns) { print $chars[$j], " "; $j = $j + $rows; $step++; } $step = 1; print "\n"; } print color 'reset'; print "Different factor for the grid? (Y/N) "; $command = ; chomp $command; } $command = "Y"; while ($command eq "Y") { print "New row order? (Y/N) "; $command = ; chomp $command; last if ($command eq "N"); print "Enter rows to print, separated by spaces: "; @rownums = split(/\s+/, ); # @rownums = split / /, $newrow if defined $_; print color 'bold blue'; foreach (@rownums){print $_, " ";} print color 'reset'; print color 'bold red'; for ($i=0; $i < $rows; $i++) { print "\n"; foreach (@rownums) { $j = ($_*$rows) - ($rows-$i); print $chars[$j], " "; } } print "\n"; print color 'reset'; print "\n"; }