I recently had occasion to try and determine the relative densities of blocks of different characters in the default font for my CLI. First I just printed out one line of each character on the screen and started to write down a list putting them in order of relative density, but this rapidly became untenable. So I set about trying to write something that would allow me to at least partially automate the process. After writing a skeleton with a couple of for loops it struck me that what I was doing was sorting the characters by a visual criteria.
Whilst I couldn't think of a simple way of having the script make the determination for me, I realised that I could use the built-in sort function to take care of the houskeeping and came up with the following script.
#! perl -slw
use strict;
use Term::ReadKey;
sub key{
my $key;
ReadMode 4;
1 while not defined( $key = ReadKey(0.1) );
ReadMode 0;
return $key;
}
my @c = (32..127);
@c = sort {
system 'cls';
print chr($a) x 16, ' ', chr($b) x 16, ' ', chr($a) x 16, ' ', chr
+($b) x 16 for 1 .. 8;
print '';
print chr($b) x 16, ' ', chr($a) x 16, ' ', chr($b) x 16, ' ', chr
+($a) x 16 for 1 .. 8;
print '';
print chr($a) x 16, ' ', chr($b) x 16, ' ', chr($a) x 16, ' ', chr
+($b) x 16 for 1 .. 8;
print '';
print chr($b) x 16, ' ', chr($a) x 16, ' ', chr($b) x 16, ' ', chr
+($a) x 16 for 1 .. 8;
print '';
print 'Enter 1 if top left is darker, 2 if they are the same, 3 if
+ top right is darker';
key()-2;
} @c;
print $_, ' : ', chr() x 50 for @c;
Whilst this particular task is not likely to be needed very often, the basic idea could be used for anything that would benefit from the A/B comparison technique. Whether it's putting your favorite bands in order of preference, or deciding which college to go to. Basically anything where it's easier to make a judgement by considering 2 things at a time rather than the a whole group together.
Silly idea, but I found it useful:)
Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.