#!/usr/bin/env perl # # isograms - prints the isograms in the input # # $Id: isograms 711 2010-03-05 23:21:52Z rp $ # An isogram is a word in which every character occurs equally often; # this script takes a word to be a maximal sequence of ASCII alphabet chars. use warnings; use strict; use Getopt::Std; my %opt; getopts('hi', \%opt); &help if $opt{h}; sub help { print <) { foreach my $w (/[a-z]+/ig) { my $w2match = $cily ? lc($w) : $w; next if $wc{$w2match}++; my %cc; foreach my $c (split(//, $w2match)) { ++$cc{$c}; } my ($c1, @cs) = values %cc; if (!grep { $_ != $c1 } @cs) { print $w, $/; } } }