#!/usr/bin/perl while (<>) { chomp; my ($block, $shapes) = split /: /; for my $shape (split m{/}, $shapes) { next unless length($shape) > 1 || $shape eq 'j' ; $count{$shape}++; push @{$blocks{$shape}}, $block; } } sub by_length { length($a) <=> length($b) || $count{$b} <=> $count{$a} || $a cmp $b } my $n = 0; for my $shape (sort by_length keys %count) { printf "%2d. %-4s: %2d\n", ++$n, $shape, $count{$shape}; if ($count{$shape} > 1) { open F, ">", "images/$shape.html" or die $!; print F "